这可能很简单,老实说,这更像是一个学习问题,因为我这个月才刚开始学习python。
这张图看上去很好,但没有图例显示,它给了我: TypeError:'<=‘不支持’矩形‘和’矩形‘之间的实例。
plt.style.use('seaborn-deep')
no_bars = plt.bar(ind, no_no_show_prop, width, alpha=.7, label='Showed up')
yes_bars = plt.bar(ind + width, yes_no_show_prop, width, alpha=.7, label='Did not show')
bins = np.linspace(0, 10, 30)
plt.hist([no_bars, yes_bars], bins)
plt.legend(loc='upper right')
plt.show()发布于 2022-08-07 21:27:38
调用plt.legend没有什么问题。您给出了上面的标签,它会很好,但是您已经用no_bars和yes_bars调用了plt.bar
您需要在结束时调用bins本身。所以,
plt.hist(bins)
plt.legend(loc='upper right')
plt.show()应该不会引起任何错误。
https://stackoverflow.com/questions/73271085
复制相似问题