相关疑难解决方法(0)

Matplotlib在子图中传说

我想把传说放在下面的每个子图中.我试过用plt.legend但它没有用.

有什么建议?

提前致谢 :-)

f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
ax1.plot(xtr, color='r', label='Blue stars')
ax2.plot(ytr, color='g')
ax3.plot(ztr, color='b')
ax1.set_title('2012/09/15')
plt.legend([ax1, ax2, ax3],["HHZ 1", "HHN", "HHE"])
plt.show()
Run Code Online (Sandbox Code Playgroud)

结果情节 根据atomh33ls的建议:

ax1.legend("HHZ 1",loc="upper right")
ax2.legend("HHN",loc="upper right")
ax3.legend("HHE",loc="upper right")
Run Code Online (Sandbox Code Playgroud)

图例位置是固定的,但是字符串似乎有问题,因为每个字母都放在一个新行中.

有谁知道如何解决它?

在此输入图像描述

python matplotlib

25
推荐指数
3
解决办法
8万
查看次数

标签 统计

matplotlib ×1

python ×1