Search code examples
pythonmatplotlibplothistogramaxes

Modify scale plot histogram


# Histogram      
x, y = np.histogram(topplesize, 1000)
plt.figure(figsize=(10,7))
plt.clf()
plt.loglog(y[0:-1],x, 'b.')
plt.title("Avalanche Size Distribution", fontsize=16)
plt.xlabel(r"$\log$" + "(Avalanche Size)", fontsize=15)
plt.ylabel(r"$\log$" + "(Frequency)", fontsize=15)
plt.show()

Hello everyone, I need to change the scale and put it the same for the two axes: both must start from 10 ^ 0, how can I do it? thanks enter image description here


Solution

  • You can set the lower limit of both the axes to your desired value. You can also write 1 instead of 10**0

    plt.xlim(10**0, None)
    plt.ylim(10**0, None)
    

    If you also want the upper limit to be the same, replace None by that value. For ex:

    plt.xlim(10**0, 10**5)
    plt.ylim(10**0, 10**5)