有关Kwargs Color参数的问题

时间:2018-09-04 06:54:32

标签: python python-3.x matplotlib histogram

尝试从我使用的数据集中绘制要素的直方图时遇到问题。我在互联网上进行了很多搜索,以找到解决方法,但没有找到。如果有人知道我有兴趣!

dataset_base = pd.read_csv(path_dataset_real, names=names,  skiprows=1, delimiter=';')
dataset_base = pd.DataFrame(dataset_base)
dataset_base['address'] = dataset_base['address'].apply(hexToint)
dataset_refl = dataset_base.loc[dataset_base['Res4H'] == 1]
dataset_true = dataset_base.loc[dataset_base['Res4H'] == 0]
dataset_true = dataset_true.loc[0:571,:]

fig, axes = plt.subplots(4,3, figsize=(10,20))
refl = dataset_refl
true = dataset_true

ax = axes.ravel()

for i in range(0,12):
    _, bins = np.histogram(dataset_base.values[:,i], bins=50)
    ax[i].hist(refl.values[:,i], bins=bins, color='red', alpha=.5)
    ax[i].hist(true.values[:,i], bins=bins, color='green', alpha=.5)
    ax[i].set_title(names[i])
    ax[i].set_yticks(())
ax[0].set_xlabel("Feature Magnitude")
ax[0].set_ylabel('Frequency')
ax[0].legend(["Refls", "Plots"], loc='best')
fig.tight_layout()
plt.show()

0 个答案:

没有答案