【发布时间】:2021-12-21 01:26:51
【问题描述】:
我正在尝试在这里绘制直方图,但我不断收到错误
numeric_features = ['tenure', 'MonthlyCharges', 'TotalCharges']
cols = 3
rows = int( np.ceil( len(numeric_features)/ cols))
fig, axes = plt.subplots(rows, cols, figsize=(16,16))
for i in range(len(numeric_features)):
this_row = int(np.floor(i/cols))
this_col = int(i%cols)
feat = numeric_features[i]
this_ax = axes[this_row][this_col]
this_ax.hist(df_train[feat], bins=25)
this_ax.set_title(feat)
plt.grid()
plt.show()
它会抛出以下错误:
我哪里错了?我只是想绘制数据集的数值。
【问题讨论】:
-
对于子图中的多个行号,格式不是
axes[this_row, this_col]吗?
标签: python pandas dataframe matplotlib