plots do not scale to size

Chaitanya Krishna <icymist@...287...> writes:

When I run the script below, the xlabel and ylabel do not show up. If I
increase the figure size, it all works fine.

I am not sure if it is a bug. But, it is usual that such a thing
happens when you are making small figures (like in your case).

Arguably it is a bug, since it is reasonable to expect that when you set
an xlabel or ylabel (or, say, large yticklabels), it shows up in the
figure. There are at least two problems to solve here: what should the
user interface be like, and how can it best be implemented?

The user interface question seems difficult to me. If you set the figure
size to something small (as in this case) and then add labels, should
matplotlib reduce the area available for the plot? Or should it reduce
the font size of the labels and the tick labels, and perhaps the amount
of white space between the axes and the labels? Or some combination of
these?

The implementation question could also be somewhat hairy, since the
bounding box of text objects depends on the backend. If agg and pdf
disagree on the size of a label, is it OK to get different-looking
results in png and pdf?

···

On Tue, Jun 9, 2009 at 12:05 PM, Paul Anton Letnes <paul.anton.letnes@...287...> wrote:

--
Jouni K. Sepp�nen
http://www.iki.fi/jks

These FAQs are also probably relevant:

http://matplotlib.sourceforge.net/faq/howto_faq.html#move-the-edge-of-an-axes-to-make-room-for-tick-labels
http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

JDH

···

On Tue, Jun 9, 2009 at 10:18 AM, Jouni K. Seppänen<jks@...397...> wrote:

Chaitanya Krishna <icymist@...287...> writes:

On Tue, Jun 9, 2009 at 12:05 PM, Paul Anton Letnes <paul.anton.letnes@...878....287...> wrote:

When I run the script below, the xlabel and ylabel do not show up. If I
increase the figure size, it all works fine.

I am not sure if it is a bug. But, it is usual that such a thing
happens when you are making small figures (like in your case).

Arguably it is a bug, since it is reasonable to expect that when you set
an xlabel or ylabel (or, say, large yticklabels), it shows up in the
figure. There are at least two problems to solve here: what should the
user interface be like, and how can it best be implemented?

This _must_ be a bug. Consider the following:

test.pdf (161 KB)

···

On 9. juni. 2009, at 17.18, Jouni K. Seppänen wrote:

Chaitanya Krishna <icymist@...287...> writes:

On Tue, Jun 9, 2009 at 12:05 PM, Paul Anton Letnes <paul.anton.letnes@...878....287... >> > wrote:

When I run the script below, the xlabel and ylabel do not show up. If I
increase the figure size, it all works fine.

I am not sure if it is a bug. But, it is usual that such a thing
happens when you are making small figures (like in your case).

Arguably it is a bug, since it is reasonable to expect that when you set
an xlabel or ylabel (or, say, large yticklabels), it shows up in the
figure. There are at least two problems to solve here: what should the
user interface be like, and how can it best be implemented?

The user interface question seems difficult to me. If you set the figure
size to something small (as in this case) and then add labels, should
matplotlib reduce the area available for the plot? Or should it reduce
the font size of the labels and the tick labels, and perhaps the amount
of white space between the axes and the labels? Or some combination of
these?

The implementation question could also be somewhat hairy, since the
bounding box of text objects depends on the backend. If agg and pdf
disagree on the size of a label, is it OK to get different-looking
results in png and pdf?

--
Jouni K. Seppänen
http://www.iki.fi/jks

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

##############
import matplotlib
matplotlib.rcParams['figure.figsize'] = [8.85, 3.20]
matplotlib.use('pdf')
from pylab import *

xs = linspace(0, 2 * pi)
ys = sin(xs)
plot(xs, ys)
xlabel(r'$T_{est}$')
ylabel('y axis')

savefig('test')
##############
Here, the vertical size is clearly large enough for a label, as it is a full inch larger than in the previous example. However, the xlabel is truncated. This _must_ be a bug. When I make a plot, I would expect that all parts of the plot appear on the plot.

As an example, in Gnuplot, the text just appears in the "right place", but is too large (overlaps the plot, etc). Hence, you see for yourself that the font size is the problem.

Anyway, it can't be the font size here, as the xlabel was completely outside the "bounding box" (I'm not sure of the terminology). To me, it just looks like a problem with the scaling - the plot looks perfectly OK in Illustrator, disregarding that it doesn't fit inside the "viewing window".

I'm not an expert, and I certainly don't know how to fix this. But I do know that other software manages this nicely. Don't get me wrong, I use matplotlib because I like it - but it should be possible to fix this problem.

Best regards,
Paul.