【发布时间】:2021-01-28 22:00:41
【问题描述】:
我有一个带有图例的 (cumulatativ, step) matplotlib 直方图。然而,我对这个传说并不完全满意。我想在那里有线条,而不是像我在左侧画的这些矩形(用我所有的绘画热情)
我不知道它是否有帮助,但这是我绘制此图的代码:
hlines = [0.2, 0.4, 0.6, 0.8, 1]
for hline in hlines:
plt.axhline(y=hline, color='lightgrey', linewidth=0.5, zorder=0.5)
plt.hist(freq_days_bw_hist1, bins=5400, density=True, cumulative=True, color='navy', label='c1', histtype='step', linewidth=2)
plt.hist(freq_days_bw_hist2, bins=5400, density=True, cumulative=True, color='red', label='c2', histtype='step', linewidth=2)
plt.rc('legend', fontsize=16)
plt.xticks(fontsize=18)
plt.yticks(fontsize=18)
#cumulative=True,
#plt.plot(po, est_exp)
axes = plt.gca()
axes.set_xlim([0, 365])
axes.set_ylim([0, 1.1])
axes.set_xlabel('days', size=20)
axes.set_ylabel('cdfs', size=20)
plt.legend(loc='upper right')
plt.show()
提前致谢!
【问题讨论】:
标签: python matplotlib legend legend-properties