【发布时间】:2021-04-05 12:41:54
【问题描述】:
我正在测试一个图表,除了图例之外的所有内容都有效。我已经运行了下面的代码,但没有在 plt.plot 中找到标签,但我仍然没有得到返回的图例。有谁知道为什么?
plt.figure(figsize=(8,5))
plt.title('Test Graph', fontdict={'fontweight':'bold', 'fontsize': 24})
plt.plot(excl.Date, excl.Pop2020, 'g.-', label = 'test')
plt.xticks(excl.Date[::4])
plt.xlabel('Date')
plt.ylabel('Pop')
plt.legend
plt.savefig('testpic.png', dpi = 300)
plt.show()
【问题讨论】:
-
plt.legend() 也许?
标签: python-3.x matplotlib