Controlling tick spacing in log-scale

matplotlib, numpy, python

Solution

Just use matplotlib.ticker.LogLocator

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import LogLocator
x = np.linspace(0, 10, 10)
y = 2**x
f = plt.figure()
ax = f.add_subplot(111)
plt.yscale('log')
ax.yaxis.set_major_locator(LogLocator(base=100))
ax.plot(x, y)
plt.show()

And do the same with minor locator if you wish, or adjust it any other way you like.

Problem

When I apply: ``` ax.set_yscale('log') ``` to an axes in matplotlib, it creates a tick for every multiple of 10. Sometimes, this can bee to much, e.g. see screenshot below: Instead, I would like to have a tick, say, every multiple of `100`, or every multiple of `1000`, while preserving a logarithmic scaling. How can I do that in matplotlib?

Original source