Matplotlib: force integer labeling of axis

#!/usr/bin/env python

from matplotlib.pyplot import figure, show
from matplotlib.ticker import MaxNLocator
#...
ax = figure().gca()
#...
ax.xaxis.set_major_locator(MaxNLocator(integer=True))

The last line makes the x-axis have integer-only labels.

You can do the same for y axis if you want.