且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在matplotlib/pylab图表中水平打印Y轴标签?

更新时间:2023-10-08 16:04:22

这非常简单.绘制标签后,您可以简单地更改旋转角度:

It is very simple. After plotting the label, you can simply change the rotation:

from matplotlib import pyplot as plt
plt.ion()
plt.plot([1,2,3])
h = plt.ylabel('y')
h.set_rotation(0)
plt.draw()

或者,您可以将旋转值作为参数传递,即

Alternatively, you can pass the rotation as an argument, i.e

plt.ylabel('y',rotation=0)