[Matplotlib-users] controlling ticks

I am plotting with semilogy. I am getting the tick labels as powers of
10, which is what I want. However, because the range of data is large, the tick
labels are every 2 powers of 10, [10^-1, 10^-3 …]

What’s the easiest way to change so that the tick labels are for each integer power of 10, [10^-1, 10^-2 …]?


Those who don’t understand recursion are doomed to repeat it

Lifted from a comment Bruno Beltran made on gitter: https://gitter.im/matplotlib/matplotlib?at=5f888b74631a250ab26f179b

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker

t = np.logspace(0, 4, 10)
fig = plt.figure()
ax = fig.add_subplot()
ax.loglog(t, t**3)

enough_ticks = matplotlib.ticker.LogLocator(numticks=15)

works, but you have to know how many ticks you want up front.

There are enough knobs on both LogFormatter and LogLocator that this seems like something that should be configurable, but I don’t know how off the top of my head (and a very quick look at the source did not have an obvious path).



Thomas Caswell