How to print Y axis label horizontally in a matplotlib / pylab chart?

前端 未结 2 1076
不知归路
不知归路 2020-12-08 12:57

I\'m creating very simple charts with matplotlib / pylab Python module. The letter \"y\" that labels the Y axis is on its side. You would expect this if the label was longer

2条回答
  •  独厮守ぢ
    2020-12-08 13:39

    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)
    

提交回复
热议问题