{axesgrid} - How to change fontsize on multiple labels?

Hello,

I am using axes_grid toolkit to create multiple axes. The labels’ colors are nicely being updated, however size or fontsize has no effect on the resulting figure :frowning: Are they functional, or is it something wrong with my implementation? Oh also I couldn’t make the grids switched on my figures.

Here is the snippet that I use:

fig = plt.figure(1)
host = SubplotHost(fig, 111)
fig.add_subplot(host)
par = host.twinx()
host.set_xlabel(“Time [sfm]”, size=50)
host.set_ylabel(“DMT CCN Concentration [#/cm^3]”, fontsize=20)
par.set_ylabel(“Supersaturation [%]”, fontsize=20)

p1, = host.plot(Time, dccnConc, label=“dccnConc”)
p2, = host.plot(Time, dccnConAmb, label=“dccnConAmb”)
p3, = host.plot(Time, dccnConSTP, label=“dccnConSTP”)
p4, = par.plot(Time, dccnSS, label=“dccnSS”)
p5, = par.plot(Time, dccnSS_Amb, label=“dccnSS_Amb”)

host.axis[“left”].label.set_color(p1.get_color())
par.axis[“right”].label.set_color(p5.get_color())

host.axis[“left”].label.set_label(p1.get_label())
host.legend()
plt.show()

These are my current system properties:

Linux 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 11)
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
IPython 0.10.bzr.r1174 (with --pylab)
and a very recent Matplotlib svn version.

Thanks.

···


Gökhan

axes_grid toolkit uses slightly customized version of axes and
different kind of artists are used to draw ticks and ticklabels, and
some of the commands from original mpl do not work.
But not changing fontsize and not showing up gridlines are things that
should be fixed (I'll work on these in a few days).
Meanwhile, there are workarounds.

For fontsize, try to directly set the font size of the label object.
Unfortunately, the padding between the label and the axis get messed
up, and you need to adjust the padding manually.

host.axis["bottom"].label.set_size(30)
host.axis["bottom"].LABELPAD=10

For grid, it is a bit more tricky.

host.xaxis.set_visible(True)
host.yaxis.set_visible(True)
host.xaxis.get_label().set_visible(False)
host.yaxis.get_label().set_visible(False)
for a in host.xaxis.majorTicks + host.yaxis.majorTicks:
    a.gridOn=True
    a.tick1On=False
    a.tick2On=False
    a.label1On=False
    a.label2On=False

I hope these workarounds are useful.
Thanks for reporting the problems and I;ll try to fix them soon.
Regards,

-JJ

···

On Wed, Jul 8, 2009 at 10:00 PM, Gökhan SEVER<gokhansever@...287...> wrote:

Hello,

I am using axes_grid toolkit to create multiple axes. The labels' colors are
nicely being updated, however size or fontsize has no effect on the
resulting figure :frowning: Are they functional, or is it something wrong with my
implementation? Oh also I couldn't make the grids switched on my figures.

Here is the snippet that I use:

fig = plt.figure(1)
host = SubplotHost(fig, 111)
fig.add_subplot(host)
par = host.twinx()
host.set_xlabel("Time [sfm]", size=50)
host.set_ylabel("DMT CCN Concentration [#/cm^3]", fontsize=20)
par.set_ylabel("Supersaturation [%]", fontsize=20)

p1, = host.plot(Time, dccnConc, label="dccnConc")
p2, = host.plot(Time, dccnConAmb, label="dccnConAmb")
p3, = host.plot(Time, dccnConSTP, label="dccnConSTP")
p4, = par.plot(Time, dccnSS, label="dccnSS")
p5, = par.plot(Time, dccnSS_Amb, label="dccnSS_Amb")

host.axis["left"].label.set_color(p1.get_color())
par.axis["right"].label.set_color(p5.get_color())

host.axis["left"].label.set_label(p1.get_label())
host.legend()
plt.show()

These are my current system properties:

Linux 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 11)
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
IPython 0.10.bzr.r1174 (with --pylab)
and a very recent Matplotlib svn version.

Thanks.

--
Gökhan

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Jae-Joon,

Your suggested work-arounds worked like a charming. See my before and after plots at the given links:

http://img34.imageshack.us/img34/3899/dccnplot1.png

http://img27.imageshack.us/img27/6274/dccnplot2.png

I have one tiny question left working on these figures; that is: how to make mathtext font and a regular label font at the same size?

For instance:

host.set_ylabel(r"DMT CCN Concentration [ #/$cm^3$]")

but as it is seen from the figure they look a bit weird.

Thank you.

PS: I am glad I could add a little bit into this great piece of visualization toolkit.

···

On Wed, Jul 8, 2009 at 9:47 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:

axes_grid toolkit uses slightly customized version of axes and

different kind of artists are used to draw ticks and ticklabels, and

some of the commands from original mpl do not work.

But not changing fontsize and not showing up gridlines are things that

should be fixed (I’ll work on these in a few days).

Meanwhile, there are workarounds.

For fontsize, try to directly set the font size of the label object.

Unfortunately, the padding between the label and the axis get messed

up, and you need to adjust the padding manually.

host.axis[“bottom”].label.set_size(30)

host.axis[“bottom”].LABELPAD=10

For grid, it is a bit more tricky.

host.xaxis.set_visible(True)

host.yaxis.set_visible(True)

host.xaxis.get_label().set_visible(False)

host.yaxis.get_label().set_visible(False)

for a in host.xaxis.majorTicks + host.yaxis.majorTicks:

a.gridOn=True

a.tick1On=False

a.tick2On=False

a.label1On=False

a.label2On=False

I hope these workarounds are useful.

Thanks for reporting the problems and I;ll try to fix them soon.

Regards,

-JJ

On Wed, Jul 8, 2009 at 10:00 PM, Gökhan SEVER<gokhansever@…287…> wrote:

Hello,

I am using axes_grid toolkit to create multiple axes. The labels’ colors are

nicely being updated, however size or fontsize has no effect on the

resulting figure :frowning: Are they functional, or is it something wrong with my

implementation? Oh also I couldn’t make the grids switched on my figures.

Here is the snippet that I use:

fig = plt.figure(1)

host = SubplotHost(fig, 111)

fig.add_subplot(host)

par = host.twinx()

host.set_xlabel(“Time [sfm]”, size=50)

host.set_ylabel(“DMT CCN Concentration [#/cm^3]”, fontsize=20)

par.set_ylabel(“Supersaturation [%]”, fontsize=20)

p1, = host.plot(Time, dccnConc, label=“dccnConc”)

p2, = host.plot(Time, dccnConAmb, label=“dccnConAmb”)

p3, = host.plot(Time, dccnConSTP, label=“dccnConSTP”)

p4, = par.plot(Time, dccnSS, label=“dccnSS”)

p5, = par.plot(Time, dccnSS_Amb, label=“dccnSS_Amb”)

host.axis[“left”].label.set_color(p1.get_color())

par.axis[“right”].label.set_color(p5.get_color())

host.axis[“left”].label.set_label(p1.get_label())

host.legend()

plt.show()

These are my current system properties:

Linux 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 11)

Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)

IPython 0.10.bzr.r1174 (with --pylab)

and a very recent Matplotlib svn version.

Thanks.

Gökhan


Enter the BlackBerry Developer Challenge

This is your chance to win up to $100,000 in prizes! For a limited time,

vendors submitting new applications to BlackBerry App World™ will have

the opportunity to enter the BlackBerry Developer Challenge. See full prize

details at: http://p.sf.net/sfu/Challenge


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Gökhan

My guess is that this is the default behavior of tex rendering, but i
may be wrong.
If you want bigger mathtext, I think you need to use tex command, but
again, i'm not sure and I hope someone else answer this.

-JJ

···

On Thu, Jul 9, 2009 at 12:40 AM, Gökhan SEVER<gokhansever@...287...> wrote:

I have one tiny question left working on these figures; that is: how to make
mathtext font and a regular label font at the same size?

For instance:

host.set_ylabel(r"DMT CCN Concentration [ #/$cm^3$]")

but as it is seen from the figure they look a bit weird.

I am studying the example given here: http://www.scipy.org/Wiki/Cookbook/Matplotlib/UsingTex

and changing the related parameters in my matplotlibrc file. However still couldn’t find the right combination to make the texts and math symbols look similar.

Any suggestion?

···

On Thu, Jul 9, 2009 at 11:08 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:

On Thu, Jul 9, 2009 at 12:40 AM, Gökhan SEVER<gokhansever@…287…> wrote:

I have one tiny question left working on these figures; that is: how to make

mathtext font and a regular label font at the same size?

For instance:

host.set_ylabel(r"DMT CCN Concentration [ #/$cm^3$]")

but as it is seen from the figure they look a bit weird.

My guess is that this is the default behavior of tex rendering, but i

may be wrong.

If you want bigger mathtext, I think you need to use tex command, but

again, i’m not sure and I hope someone else answer this.

-JJ


Gökhan

Gökhan SEVER wrote:

Your suggested work-arounds worked like a charming. See my before and after plots at the given links:

http://img34.imageshack.us/img34/3899/dccnplot1.png
http://img27.imageshack.us/img27/6274/dccnplot2.png

I have one tiny question left working on these figures; that is: how to make mathtext font and a regular label font at the same size?

For instance:

host.set_ylabel(r"DMT CCN Concentration [ #/$cm^3$]")

but as it is seen from the figure they look a bit weird.

It will be impossible to get these two fonts appearing as the same size, but you can make the math rendering use the same font as the rest of the text by setting "mathtext.default" to "regular" (assuming "text.usetex" is False).

Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Thanks Mike.

This was what I been looking for. Now the unit and the actual text label looks much nicer.

Is this information available somewhere on the documentation? If not I may add…

···

On Fri, Jul 10, 2009 at 10:15 AM, Michael Droettboom <mdroe@…86…> wrote:

Gökhan SEVER wrote:

Your suggested work-arounds worked like a charming. See my before and after plots at the given links:

http://img34.imageshack.us/img34/3899/dccnplot1.png

http://img27.imageshack.us/img27/6274/dccnplot2.png

I have one tiny question left working on these figures; that is: how to make mathtext font and a regular label font at the same size?

For instance:

host.set_ylabel(r"DMT CCN Concentration [ #/$cm^3$]")

but as it is seen from the figure they look a bit weird.

It will be impossible to get these two fonts appearing as the same size, but you can make the math rendering use the same font as the rest of the text by setting “mathtext.default” to “regular” (assuming “text.usetex” is False).

Mike

Michael Droettboom

Science Software Branch

Operations and Engineering Division

Space Telescope Science Institute

Operated by AURA for NASA


Gökhan