SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Sandro T. <mo...@de...> - 2009年02月28日 01:02:48
Attachments: 7900_02_06.png
Hi!
I have this configuration file:
$ cat matplotlibrc
figure.figsize : 4, 3
figure.dpi	 : 300
savefig.dpi	 : 300
font.size	 : 9.0
and using this code
import matplotlib.pyplot as plt
plt.plot([1, 2, 3])
plt.xlabel('This is the X axis')
plt.ylabel('This is the Y axis')
plt.savefig('7900_02_06.png')
I obtain the attached image that, as you can see, has xlabel tect cut.
What is the best way to avoid it? reducing the actual "plot" area
(axes and line)? or reducing the font size?
Now that I look better at it, isn't it a bug after all? I see ylabel
correctly rendered, and xlabel not (but it's late in the night, so I
might be mistaken :) ) .
Thanks in advance,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: Eric F. <ef...@ha...> - 2009年02月28日 19:56:56
Sandro Tosi wrote:
> Hi!
> I have this configuration file:
> 
> $ cat matplotlibrc
> figure.figsize : 4, 3
> figure.dpi	 : 300
> savefig.dpi	 : 300
> font.size	 : 9.0
> 
> and using this code
> 
> import matplotlib.pyplot as plt
> plt.plot([1, 2, 3])
> plt.xlabel('This is the X axis')
> plt.ylabel('This is the Y axis')
> plt.savefig('7900_02_06.png')
> 
> I obtain the attached image that, as you can see, has xlabel tect cut.
> 
> What is the best way to avoid it? reducing the actual "plot" area
> (axes and line)? or reducing the font size?
> 
> Now that I look better at it, isn't it a bug after all? I see ylabel
> correctly rendered, and xlabel not (but it's late in the night, so I
> might be mistaken :) ) .
It is not really a bug; it is an inherent limitation in mpl's default 
automatic Axes positioning. Axes positions are given in normalized 
coordinates relative to the figure, so if you shrink the height of the 
figure (relative to the default, for which the default positioning 
parameters are designed), there is less physical space available for the 
x-axis ticks, ticklabels, and label--and things can get cut off. If you 
are adjusting the figsize and/or the font size, then chances are you 
need to adjust these normalized coordinate Axes position parameters as 
well. Trial and error is typically needed; it can be facilitated by 
using the subplot adjuster widget in an interactive window (second to 
last button on the toolbar) to decide what looks good. Then use the 
figure.subplot.* entries in matplotlibrc, or call 
plt.subplots_adjust(bottom=0.15) (for example), or call it as a method 
of the figure you have just created.
For doing the interactive adjustment, you will want to use a smaller 
figure dpi, something to match your screen. Everything will scale 
correctly when you save the figure at higher dpi.
Eric
> 
> Thanks in advance,
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a 600ドル discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Sandro T. <mo...@de...> - 2009年03月03日 21:46:19
Hi Eric,
thanks for the reply.
On Sat, Feb 28, 2009 at 20:56, Eric Firing <ef...@ha...> wrote:
> It is not really a bug; it is an inherent limitation in mpl's default
> automatic Axes positioning. Axes positions are given in normalized
> coordinates relative to the figure, so if you shrink the height of the
> figure (relative to the default, for which the default positioning
> parameters are designed), there is less physical space available for the
> x-axis ticks, ticklabels, and label--and things can get cut off. If you are
> adjusting the figsize and/or the font size, then chances are you need to
> adjust these normalized coordinate Axes position parameters as well. Trial
Oh, ok, now it's clear
> and error is typically needed; it can be facilitated by using the subplot
> adjuster widget in an interactive window (second to last button on the
> toolbar) to decide what looks good. Then use the figure.subplot.* entries
Yeah, I used this to find 0.13 to be my number...
> in matplotlibrc, or call plt.subplots_adjust(bottom=0.15) (for example), or
> call it as a method of the figure you have just created.
...that I added this command and it worked.
> For doing the interactive adjustment, you will want to use a smaller figure
> dpi, something to match your screen. Everything will scale correctly when
> you save the figure at higher dpi.
luckily, even at dpi=300, the image still fits my screen :)
Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /