Setting tick labelsize programatically

[Trying one more time.]

I've read docs, search the list archive, and tried to step through code.

How can I set things like xtick.labelsize and ytick.labelsize via the
object oriented interface? I have a graph object, and I can't find
anywhere in the data structure for the completed graph where the tick
label sizes are stored, nor can I find functions to set them.

Even with lots of stepping through code, I can't find where I would
manually set the size of the ticks.

I know about matplotlib.rc, and the setting in the config file, but I
don't want to set things globally, I want to set per graph.

Thanks for any pointers!

j

···

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE

[Trying one more time.]

I've read docs, search the list archive, and tried to step through code.

The docs you are looking for are
http://matplotlib.sourceforge.net/users/artists.html.

How can I set things like xtick.labelsize and ytick.labelsize via the
object oriented interface? I have a graph object, and I can't find
anywhere in the data structure for the completed graph where the tick
label sizes are stored, nor can I find functions to set them.

Here is one way to do it::

    for label in ax.get_xticklabels() + ax.get_yticklabels():
       label.set_fontsize(12)

But the artist tutorial above will give you a more in-depth
explanation of the various containers and methods.

JDH

···

On Tue, Nov 4, 2008 at 3:13 PM, Joshua J. Kugler <joshua@...1552...> wrote:

On Tuesday 04 November 2008, John Hunter said something like:

···

On Tue, Nov 4, 2008 at 3:13 PM, Joshua J. Kugler <joshua@...1552...> wrote:
> [Trying one more time.]
>
> I've read docs, search the list archive, and tried to step through
> code.

The docs you are looking for are
http://matplotlib.sourceforge.net/users/artists.html.

> How can I set things like xtick.labelsize and ytick.labelsize via
> the object oriented interface? I have a graph object, and I can't
> find anywhere in the data structure for the completed graph where
> the tick label sizes are stored, nor can I find functions to set
> them.

Here is one way to do it::

    for label in ax.get_xticklabels() + ax.get_yticklabels():
       label.set_fontsize(12)

But the artist tutorial above will give you a more in-depth
explanation of the various containers and methods.

Sigh...how simple. Thank you very much!

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE

On Tuesday 04 November 2008, Joshua J. Kugler said something like:

> Here is one way to do it::
>
> for label in ax.get_xticklabels() + ax.get_yticklabels():
> label.set_fontsize(12)
>
> But the artist tutorial above will give you a more in-depth
> explanation of the various containers and methods.

Sigh...how simple. Thank you very much!

OK, so it's half working. :slight_smile:

I have code such as this:

    for label in self.main_axes.get_xticklabels():
        tick.label.set_fontsize(self.xtick_labelsize)

    main_ticks = self.main_axes.get_yticklabels()
    sub_ticks = (self.sub_axes.get_yticklabels()
                 if hasattr(self.sub_axes, 'get_yticklabels') else )
    for label in main_ticks + sub_ticks:
        label.set_fontsize(self.ytick_labelsize)

'self' is an object that gets turned in to a plot on a figure.
the sub_axes are because we have centigrade on one end of the plot, and
Fahrenheit on the other end. The yticklabel code works fine. The
xticklabel code has no effect.

The X axis is an AutoDateLocator and apparently set_fontsize isn't
having an effect with that. I tried setting the font size even after
setting the locator, and that doesn't appear to have any effect. Can
you point me to the relevant docs on the subject? :slight_smile:

Thanks!

j

···

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE

From: Joshua J. Kugler [mailto:joshua@…1552…]
Sent: Tuesday, November 04, 2008 18:39

On Tuesday 04 November 2008, Joshua J. Kugler said something like:
> > Here is one way to do it::
> >
> > for label in ax.get_xticklabels() + ax.get_yticklabels():
> > label.set_fontsize(12)
> >
> > But the artist tutorial above will give you a more in-depth
> > explanation of the various containers and methods.
>
> Sigh...how simple. Thank you very much!

OK, so it's half working. :slight_smile:

I have code such as this:

    for label in self.main_axes.get_xticklabels():
        tick.label.set_fontsize(self.xtick_labelsize)

Perhaps the line above should be

    label.set_fontsize(self.xtick_labelsize)

instead.

···

-----Original Message-----

    main_ticks = self.main_axes.get_yticklabels()
    sub_ticks = (self.sub_axes.get_yticklabels()
                 if hasattr(self.sub_axes, 'get_yticklabels')
else )
    for label in main_ticks + sub_ticks:
        label.set_fontsize(self.ytick_labelsize)

'self' is an object that gets turned in to a plot on a figure.
the sub_axes are because we have centigrade on one end of the
plot, and Fahrenheit on the other end. The yticklabel code
works fine. The xticklabel code has no effect.

The X axis is an AutoDateLocator and apparently set_fontsize
isn't having an effect with that. I tried setting the font
size even after setting the locator, and that doesn't appear
to have any effect. Can you point me to the relevant docs on
the subject? :slight_smile:

Thanks!

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE

On Wednesday 05 November 2008, Stan West said something like:

> From: Joshua J. Kugler [mailto:joshua@…1552…]
> Sent: Tuesday, November 04, 2008 18:39
>
> On Tuesday 04 November 2008, Joshua J. Kugler said something like:
> > > Here is one way to do it::
> > >
> > > for label in ax.get_xticklabels() + ax.get_yticklabels():
> > > label.set_fontsize(12)
> > >
> > > But the artist tutorial above will give you a more in-depth
> > > explanation of the various containers and methods.
> >
> > Sigh...how simple. Thank you very much!
>
> OK, so it's half working. :slight_smile:
>
> I have code such as this:
>
> for label in self.main_axes.get_xticklabels():
> tick.label.set_fontsize(self.xtick_labelsize)

Perhaps the line above should be

    label.set_fontsize(self.xtick_labelsize)

instead.

Well, yes, it should, and I apparently caught that bug AFTER I sent the
e-mail, but alas it was left over from messing around with the code.
The code is now correct:

for label in self.main_axes.get_xticklabels():
    label.set_fontsize(self.xtick_labelsize)

But still does not affect the x date labels. Thanks for the pointer,
though!

j

···

> -----Original Message-----

> main_ticks = self.main_axes.get_yticklabels()
> sub_ticks = (self.sub_axes.get_yticklabels()
> if hasattr(self.sub_axes, 'get_yticklabels')
> else )
> for label in main_ticks + sub_ticks:
> label.set_fontsize(self.ytick_labelsize)
>
> 'self' is an object that gets turned in to a plot on a figure.
> the sub_axes are because we have centigrade on one end of the
> plot, and Fahrenheit on the other end. The yticklabel code
> works fine. The xticklabel code has no effect.
>
> The X axis is an AutoDateLocator and apparently set_fontsize
> isn't having an effect with that. I tried setting the font
> size even after setting the locator, and that doesn't appear
> to have any effect. Can you point me to the relevant docs on
> the subject? :slight_smile:
>
> Thanks!

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE