1

I would like to know if there is a practical way to vary the scale of an axis with matplotlib. More precisely, larger scale for small numbers and smaller scale for large numbers. I have the following code snippet:

x = [0,15,546,6076,10694,12000]
x = [float(y)/100 for y in x]
y = [0,0,1,2,3,4] 
plt.step(x, y)

plt.xlim([0, 150])
plt.ylim([0,10])    
plt.xticks(x,rotation='vertical')
plt.yticks(y)

plt.show()

And the resulting graph is the following: enter image description here

Basically, the 0 and 0.1 label overlaps so I would like a larger scale for small numbers and smaller scale for large numbers.

Thank you very much in advance for the help!

Cheers, Giovanni

1 Answer 1

2

You may want to look into using a logarithmic scale for your graph. It may solve your issue. You can do this by adding:

plt.yscale('log')
plt.xscale('log')

To your code before plt.show()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.