t = arange(0.0, 100.0, 0.1)
s = sin(0.1 * pi * t) * exp(-t * 0.01)
ax = subplot(111)
plot(t, s)
ax.xaxis.set_major_locator(MultipleLocator(20))
ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.xaxis.set_minor_locator(MultipleLocator(5))
ax.yaxis.set_major_locator(MultipleLocator(0.5))
ax.yaxis.set_minor_locator(MultipleLocator(0.1))
ax.xaxis.grid(True, 'minor')
ax.yaxis.grid(True, 'minor')
ax.xaxis.grid(True, 'major', linewidth=2)
ax.yaxis.grid(True, 'major', linewidth=2)
show()
Multiple grids on matplotlib