Distance between axis and axis label

Hi,

I am a new user of matplotlib (0.82; python 2.3.5). So far I have
used supermongo (sic!) to produce figures for physics journal articles
and talks. I am trying to get up to speed with matplotlib to do the
same kind of plots with an open source package.

For talks I like to prepare eps figures which I embed in my latex-based
slides. For slides, huge font sizes are a must, hence I like to use
large fonts for tick mark labels and axis labels. My problem: For the
axis labels, matplolib (or the PS backend?) is apparently not
adjusting (or rather: under-adjusting) the distance between axis and
axis label.

Is there a way to adjust the distance between an axis and its label?
If not, then where in the code is the distance calculated, scaled and
set? I have dug through the code, but could not find it due
to lack of object-oriented programming experience, I guess.

Here is an example of what I mean. The x-axis labels comes out
sort of okay, but the y-axis label is to close to the y axis.

#!/usr/bin/python
from pylab import *
from matplotlib import rcParams

plot([1,2,3,4], [1,4,9,16], 'ro')
xlabel("something",size=30)
ylabel("something else",size=30)
xlabels = getp(gca(), 'xticklabels')
setp(xlabels, size=25)
ylabels = getp(gca(), 'yticklabels')
setp(ylabels, size=25)
savefig("testplot.eps")

Note that playing around with 'axes' did not help - it has
no influence on the distance between labels and axes.

Help & comments much appreciated! Thanks!

- Christian

Christian,

Insert

rcParams['tick.major.pad'] = 12

as the third line in your script, or change the value in your matplotlibrc file.

Eric

···

For talks I like to prepare eps figures which I embed in my latex-based
slides. For slides, huge font sizes are a must, hence I like to use
large fonts for tick mark labels and axis labels. My problem: For the
axis labels, matplolib (or the PS backend?) is apparently not
adjusting (or rather: under-adjusting) the distance between axis and
axis label.

Is there a way to adjust the distance between an axis and its label?
If not, then where in the code is the distance calculated, scaled and
set? I have dug through the code, but could not find it due
to lack of object-oriented programming experience, I guess.

Here is an example of what I mean. The x-axis labels comes out
sort of okay, but the y-axis label is to close to the y axis.

#!/usr/bin/python
from pylab import *
from matplotlib import rcParams

plot([1,2,3,4], [1,4,9,16], 'ro')
xlabel("something",size=30)
ylabel("something else",size=30)
xlabels = getp(gca(), 'xticklabels')
setp(xlabels, size=25)
ylabels = getp(gca(), 'yticklabels')
setp(ylabels, size=25)
savefig("testplot.eps")

Hi Eric,

Insert

rcParams['tick.major.pad'] = 12

as the third line in your script, or change the value in your
matplotlibrc file.

thanks. But this merely changes the distance between ticks and tick
labels. The distance between tick labels and axis label stays
constant. To be more precise about what I need (my first e-mail was a
bit ambigous...sorry): I need to change the distance between tick
labels and the axis label.

Thanks.

- Christian

···

On 11/16/05, Eric Firing <efiring@...202...> wrote:

I am confused as to what the problem is. Are you saying that your
axis label is running into you tick label? Can you post a little
piece of a png showing the problem you are trying to solve?

Ryan

···

On 11/16/05, Christian David Ott <christian.d.ott@...287...> wrote:

Hi Eric,

On 11/16/05, Eric Firing <efiring@...202...> wrote:

> Insert
>
> rcParams['tick.major.pad'] = 12
>
> as the third line in your script, or change the value in your
> matplotlibrc file.

thanks. But this merely changes the distance between ticks and tick
labels. The distance between tick labels and axis label stays
constant. To be more precise about what I need (my first e-mail was a
bit ambigous...sorry): I need to change the distance between tick
labels and the axis label.

Thanks.

- Christian

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&opclick
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi Ryan,

···

On 11/16/05, Ryan Krauss <ryanlists@...287...> wrote:

I am confused as to what the problem is. Are you saying that your
axis label is running into you tick label? Can you post a little
piece of a png showing the problem you are trying to solve?

sorry, I don't know how to post a png to the mailinglist. Do I just
have to attach it to my response? Anyway, the below code generates a
plot that reproduces my problem. The y-axis label is to close to the
y-axis tick labels (though not overlapping). I would like to shift the
y-axis label further away from the y-axis tick labels.

- Christian

-------------

#!/usr/bin/python
from pylab import *
from matplotlib import rcParams

plot([1,2,3,4], [1,4,9,16], 'ro')
xlabel("something",size=30)
ylabel("something else",size=30)
xlabels = getp(gca(), 'xticklabels')
setp(xlabels, size=25)
ylabels = getp(gca(), 'yticklabels')
setp(ylabels, size=25)
savefig("testplot.eps")

I know correctly understand your problem, but I don't know how to fix
it. It seems you need a pad setting for the distance from the axis
label to the tick mark labels, but I don't see one in the rc file.

Anyone else?

Ryan

···

On 11/16/05, Christian David Ott <christian.d.ott@...287...> wrote:

Hi Ryan,

On 11/16/05, Ryan Krauss <ryanlists@...287...> wrote:
> I am confused as to what the problem is. Are you saying that your
> axis label is running into you tick label? Can you post a little
> piece of a png showing the problem you are trying to solve?

sorry, I don't know how to post a png to the mailinglist. Do I just
have to attach it to my response? Anyway, the below code generates a
plot that reproduces my problem. The y-axis label is to close to the
y-axis tick labels (though not overlapping). I would like to shift the
y-axis label further away from the y-axis tick labels.

- Christian

-------------

#!/usr/bin/python
from pylab import *
from matplotlib import rcParams

plot([1,2,3,4], [1,4,9,16], 'ro')
xlabel("something",size=30)
ylabel("something else",size=30)
xlabels = getp(gca(), 'xticklabels')
setp(xlabels, size=25)
ylabels = getp(gca(), 'yticklabels')
setp(ylabels, size=25)
savefig("testplot.eps")

Sorry I can't help you with your problem, but I can offer an alternate solution:

Rather than make the font really big, you could make the figure small, then scale the whole thing up, so that everything is bigger. This could work great for scalable back-ends like EPS. If you need a PNG, you should be able to accomplish it by manipulating the size and the dpi settings. See:

http://www.scipy.org/wikis/topical_software/AdjustingImageSize

For more info about this.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...