Matplotlib axes label

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Fri Mar 2 00:53:35 EST 2007


On Mar 1, 3:10 pm, "John Henry" <john106he... at hotmail.com> wrote:
> I've been asking this question at the matplotlib user list and never
> gotten an answer.  I am hoping that there are matplotlib users here
> that can help.
>
> My problem with matplotlib's way of handling axes label is illustrated
> by this example:
>
> http://www.scipy.org/Cookbook/Matplotlib/MulticoloredLine
>
> Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
> -1.0.

(snipped)

> Is there a way to force the label to start at -1.1 instead of -1.0?
>
> Thanks,


You can try adjusting the labels and ticks
using matplotlib.ticker.

To the example you cited, one can add

from matplotlib.ticker import MultipleLocator, FormatStrFormatter

# ...

minorLocator = MultipleLocator(0.1)
minorFormattor = FormatStrFormatter('%0.1f')
ax.yaxis.set_minor_locator(minorLocator)
ax.yaxis.set_minor_formatter(minorFormattor)

show()

--
Hope this helps,
Steven




More information about the Python-list mailing list