There are a few methods given on this page (semilogx, semilogy, loglog) but they all do the same thing under the hood, which is to call set_xscale('log')
(for x-axis) and set_yscale('log')
(for y-axis). Moreover, plt.yscale
/plt.scale
are functions in the state-machine, which make calls to set_yscale
/set_xscale
on the current Axes objects. Even for bar-charts (and histograms too since they are just bar-charts), the log=True
parameter makes calls to set_yscale('log')
/set_xscale('log')
depending on the bar orientation.
So it doesn't matter which one you use, they all end up calling the same method anyway. By the way, on top of being able to choose the base of the log, you can also set minor tick locations in the same function call (using subs
kwarg).
data = np.random.choice(np.logspace(-0.5, 1, base=20), 10)
plt.plot(data)
plt.yscale('log', base=10, subs=[10**x for x in (0.25, 0.5, 0.75)], nonpositive='mask')
# ^^^ <-- 3 equal-spaced minor ticks ^^^^ mask invalid values
