In matplotlib, sometime the major-ticks are too close to each other in a loglog
plot. Instead of setting them manually, can one use something similar to MaxNLocator
to put ticks at n-locations in a log scale?
import numpy as np
import pylab as p
x=np.logspace(1,20,10)
fig=p.figure()
ax1=fig.add_subplot(121)
ax1.loglog(x,x,'o')
ax2=fig.add_subplot(122)
ax2.loglog(x,x,'o')
fig.show()
In the newest version of matplotlib (1.2.0), to get something more similar to MaxNLocator
you could also use @unutbu 's solution with
ax.xaxis.set_major_locator(ticker.LogLocator(numticks=6))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With