np.random.seed(19680801)
n_bins = 10
x = np.random.randn(3, 3)
fig, axes = plt.subplots(nrows=1, ncols=2)
ax0, ax1= axes.flatten()
colors = ['red', 'b', 'lime']
ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors)
ax0.set_ylabel('scr')
ax0.legend(prop={'size': 10})
ax0.set_title('bars with legend')
ax1.hist(x, n_bins, density=True, histtype='barstacked')
ax1.set_title('stacked bar')
fig.tight_layout()
plt.show()
1.matplotlib进行简单图表绘制
最新推荐文章于 2024-01-12 19:49:45 发布