xlabel cropped

Hello!

I have that snipped to create a plot:

import matplotlib.pyplot as plt
size = (6.1, 3.5)
fig = plt.figure(figsize=size)
plt.xlabel("$x/l_F$")

it's being saved as eps for latex. At the size given the "F" from l_F is
truncated just a little bit. It works well if I change y-size to 3.6 but that
makes latex place to figure on a seperate page which I do not want.

Is this behavior by design or a bug? How can I give just 0.1 more y-space to
the xlabel without altering the overall size?

Thanks,
Florian

Ok, I should have read to docu before googling.

plt.xlabel("x/l\_F", labelpad = -0.1)
did it.

Sorry for bothering...

Florian

···

Am Mittwoch, 3. Juli 2013, 20:02:30 schrieb Florian Lindner:

Hello!

I have that snipped to create a plot:

import matplotlib.pyplot as plt
size = (6.1, 3.5)
fig = plt.figure(figsize=size)
plt.xlabel("x/l\_F")

it's being saved as eps for latex. At the size given the "F" from l_F is
truncated just a little bit. It works well if I change y-size to 3.6 but
that makes latex place to figure on a seperate page which I do not want.

Is this behavior by design or a bug? How can I give just 0.1 more y-space to
the xlabel without altering the overall size?

Not a bother. This is a fairly common problem because matplotlib, by design, does not handle layouts for you. If you are looking for an automated way of handling this, there is plt.tight_layout(), which is a feature that was added in v1.2, IIRC, that tries adjusting certain spacing and size parameters automatically in an effort to keep everything inside the figure space. However, a solution like yours is often perfered because it gives you explicit control over the plot, and is guaranteed to work the same way, every time.

Cheers!
Ben Root

···

On Wed, Jul 3, 2013 at 2:08 PM, Florian Lindner <mailinglists@…606…> wrote:

Am Mittwoch, 3. Juli 2013, 20:02:30 schrieb Florian Lindner:

Hello!

I have that snipped to create a plot:

import matplotlib.pyplot as plt

size = (6.1, 3.5)

fig = plt.figure(figsize=size)

plt.xlabel(“x/l_F”)

it’s being saved as eps for latex. At the size given the “F” from l_F is

truncated just a little bit. It works well if I change y-size to 3.6 but

that makes latex place to figure on a seperate page which I do not want.

Is this behavior by design or a bug? How can I give just 0.1 more y-space to

the xlabel without altering the overall size?

Ok, I should have read to docu before googling.

plt.xlabel(“x/l_F”, labelpad = -0.1)

did it.

Sorry for bothering…

Florian


This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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