[Python] Rotating the y-axis label

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to rotate the title of the Y axis so it is horizontal. I do not want the tick labels horizontal just the title of the Y axis. I have to use subplots as I am making multiple plots at once. Here is the below script in which I have tried to rotate the Y axis title.

    import matplotlib.pyplot as plt
    import sys

    fig, ax = plt.subplots()

    ax.set_title(r'$\alpha$ > \beta_i$', fontsize=20)
    ax.set(xlabel='meters $10^1$', ylabel=r'Hertz $(\frac{1}{s})$')
    ax.set(xlabel=r's(t) = \mathcal(A)\/\sin(2 \omega t)', ylabel=r'Hertz $(\frac{1}{s})$')
    ax.set(ylabel="North $\uparrow$",fontsize=9,rotate=90)
    plt.show()


    When I run it I get an error:


    TypeError: There is no AxesSubplot property "rotate"
    ​

    How can I tweak this program so that the Y axis is rotating horizontally?

    Continue reading...

Compartilhe esta Página