Log and semi-log plots

The semilogx, semilogy and loglog commands generate log scaling on the respective axes. The lower subplot uses a base10 log on the xaxis and a base 4 log on the y. Thanks to Andrew Straw, Darren Dale and Gregory Lielens for contributions to the log scaling infrastructure.

import pylab as pl

dt = 0.01
t = pl.arange(dt, 20.0, dt)

pl.subplot(211)
pl.semilogx(t, sin(2*pi*t))
pl.ylabel('semilog')
pl.xticks([])
pl.setp(gca(), 'xticklabels', [])
pl.grid(True)

pl.subplot(212)
pl.loglog(t, 20*pl.exp(-t/10.0), basey=4)
pl.grid(True)
pl.gca().xaxis.grid(True, which='minor')  # minor grid on too
pl.xlabel('time (s)')
pl.ylabel('loglog')