首页 > 解决方案 > 图例和 x 标签问题

问题描述

我几乎有一个不错的情节,但也有问题。第一个: x 标签不显示。第二个问题:我不能把第二行的名字放在图例中。我只有一个名字(关闭),我还需要“KGHM”。

fig, ax = plt.subplots()
ax.plot(x,y)

ax2 = ax.twinx()
ax2.plot(x1,y1, 'y-')

myFmt = DateFormatter("%d-%m-%y")
ax.xaxis.set_major_formatter(myFmt)

fig.autofmt_xdate()
plt.tight_layout()

plt.xlabel('PLN',size=10)
plt.ylabel('Points',size=10)
plt.title('KGHM')
ax.grid(True)

ax.legend()

plt.show()

在此处输入图像描述

感谢帮助 !

标签: python-3.xmatplotlibplotlegend

解决方案


推荐阅读