[Python] Matplotlib Histogram scale y-axis by a constant factor

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    Im plotting some values in a histogram and want to scale the y-axis but I only find ways to either normalize the y-axis values or to scale them logarithmically. My values are in 100ps timesteps and I want to multiply every y-axis value by 0.1 to get to a nice and easier to understand ns step size.

    How can I scale the y-axis values in a histogram ?

    n, bins, patches = plt.hist(values1, 50, facecolor='blue', alpha=0.9, label="Sample1",align='left')
    n, bins, patches = plt.hist(values2, 50, facecolor='red', alpha=0.9, label="Sample2",align='left')
    plt.xlabel('value')
    plt.ylabel('time [100ps]')
    plt.title('')
    plt.axis([-200, 200, 0, 180])


    plt.legend()
    plt.show()


    In this graph 10 on the y axis means 1ns:

    [​IMG]

    Continue reading...

Compartilhe esta Página