嗨,我有一个包含 95 列的数据框,其中是不同度量的 Max()、Min() 和 Avg() 值,我想在 3 列和 32 行的 facetgrid 上绘制它们的直方图,其中第一列是最大值,第二列是平均值,第 3 个是最小值,行是度量值。
我现在有这个代码:
fig, axes = plt.subplots(nrows=32, ncols=3, figsize=(20, 96))
columnas_numeric = df_agg_new.select_dtypes(include=['float64', 'int64']).columns
columnas_numeric = columnas_numeric.drop('season')
for i, colum in enumerate(columns):
if colum.endswith('Max'):
sns.histplot(
data = df_agg_new,
x = colum,
stat = "count",
kde = True,
line_kws = {'linewidth': 2},
alpha = 0.3,
ax = axes[int(i/3)][0]
)
axes[int(i/3)][0].set_title(colum, fontsize = 7, fontweight = "bold")
axes[int(i/3)][0].tick_params(labelsize = 6)
axes[int(i/3)][0].set_xlabel("")
elif colum.endswith('Avg'):
sns.histplot(
data = df_agg_new,
x = colum,
stat = "count",
kde = True,
line_kws = {'linewidth': 2},
alpha = 0.3,
ax = axes[int(i/3)][1]
)
axes[int(i/3)][1].set_title(colum, fontsize = 7, fontweight = "bold")
axes[int(i/3)][1].tick_params(labelsize = 6)
axes[int(i/3)][1].set_xlabel("")
else:
sns.histplot(
data = df_agg_new,
x = colum,
stat = "count",
kde = True,
line_kws = {'linewidth': 2},
alpha = 0.3,
ax = axes[int(i/3)][2]
)
axes[int(i/3)][2].set_title(colum, fontsize = 7, fontweight = "bold")
axes[int(i/3)][2].tick_params(labelsize = 6)
axes[int(i/3)][2].set_xlabel("")
fig.tight_layout()
plt.subplots_adjust(top = 0.97)
fig.suptitle('Distribution plots', fontsize = 10, fontweight = "bold");
但是不工作,因为一些度量值转到其他行