図に統計情報表示
This commit is contained in:
@@ -443,7 +443,6 @@ def plot_data(data, lower=10, upper=None, target_lab=10, bin_width=10):
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
df = data.copy()
|
||||
|
||||
df = filter_plot_data(df, lower=lower, upper=upper)
|
||||
labs = sorted(df["研究室番号"].unique())
|
||||
target_values = df.loc[df["研究室番号"] ==
|
||||
@@ -465,6 +464,23 @@ def plot_data(data, lower=10, upper=None, target_lab=10, bin_width=10):
|
||||
draw_gp_histogram(axs[1], df, target_values,
|
||||
bin_width, colors[0], colors[3])
|
||||
|
||||
describe_text = df["値"].describe()
|
||||
describe_text = describe_text.to_string(float_format=lambda x: f"{x:.1f}")
|
||||
# 下段ヒストグラムの右上に describe() を表示
|
||||
axs[1].text(
|
||||
0.01, 0.99, # Axes 内の右上
|
||||
describe_text,
|
||||
transform=axs[1].transAxes,
|
||||
ha="left", va="top", fontsize=8,
|
||||
fontfamily="monospace", # 桁を揃える
|
||||
bbox={
|
||||
"facecolor": "white",
|
||||
"edgecolor": "gray",
|
||||
"alpha": 0.85,
|
||||
"boxstyle": "round,pad=0.2",
|
||||
},
|
||||
zorder=1,
|
||||
)
|
||||
for ax in axs:
|
||||
style_axis(ax)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user