Restrict axis to integer tick locations

You can use the MaxNLocator method, like so:

    from pylab import MaxNLocator

    ya = axes.get_yaxis()
    ya.set_major_locator(MaxNLocator(integer=True))

Leave a Comment