Matplotlib axes label

John Henry john106henry at hotmail.com
Fri Mar 2 16:02:39 CET 2007


On Mar 1, 10:07 pm, "John Henry" <john106he... at hotmail.com> wrote:
> On Mar 1, 9:53 pm, attn.steven.... at gmail.com wrote:
>
>
>
> > 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
>
> Thank you for the response.  Yes, adding those lines did work.
>
> But what exactly is going on here?  Why would adding these two lines
> works?
>
> Thanks,


Okay, I played with the ticker formater and locator routines.
Unfortunately, it doesn't help.  The locator sets the major value and
the formatter determines how the axes label is formatted.  It doesn't
gurantee that the first label starts at the origin.  Half of my plots
works, and half of them doesn't.




More information about the Python-list mailing list