hist的官方文档,下面的例子值得学习
在一个图上画三个数据集
下述图的问题:
- 都不咋好看
- 由于第二个length太高了,导致其他的length区分度不大了
- 不同数据集有些length重合了……
- 横坐标的位置和bar不匹配
- 方法1
fig, ax = plt.subplots(nrows = 1, ncols = 1)
colors = ['red', 'green', 'orange']
ax.hist(train_length, n_bins, color = 'red')
ax.hist(evaluation_length, n_bins, color = 'green')
ax.hist(experimental_length, n_bins, color = 'orange')
fig.tight_layout()
plt.show()
- 方法2
fig, ax = plt.subplots(nrows = 1, ncols = 1, figsize = (10, 5))
colors = ['red', 'green', 'orange']
ax.hist([train_length, evaluation_length, experimental_length], n_bins, histtype='bar', stacked=True)
fig.tight_layout()
plt.show()
- 方法3
fig, ax = plt.subplots(nrows = 1, ncols = 1, figsize = (10, 5))
colo