Hi everyone,

We're having a problem in Sage where if we specify the dpi of a figure, the bottom of the figure is cut off, but only the first time we save it. If we save the figure again, with the same arguments, the resulting image looks fine. I'm puzzled whether this is a Sage problem or a problem with interfacing with matplotlib, since it only happens when we are launch Sage (as opposed to just launching the ipython that Sage uses).

More details:

Running the following code in the Sage notebook or from the Sage command line gives a figure in which the bottom is cut off and the file is 12K instead of 13K. While firefox displays an image in which the bottom is cut off, eog (the gnome image viewer) doesn't even display the image, so I think the image might be corrupted. When I open the image with Konqueror, it seems like the cut off part of the image (about the lower quarter of the image) is completely transparent. I've attached the cut off image.

import matplotlib.pyplot as plt
import numpy
plt.figure()
plt.plot(numpy.arange(0,1.1,0.01))
plt.savefig('foo.png',dpi=72)


However, if we immediately save the figure again:

plt.savefig('foo.png',dpi=72)

the resulting image looks fine (i.e., the bottom is not cut off, the file is 13K, and eog displays it).


If we run the same code again using "sage -ipython" (which just launches Sage's ipython, without any Sage initialization), the same code:

import matplotlib.pyplot as plt
import numpy
plt.figure()
plt.plot(numpy.arange(0,1.1,0.01))
plt.savefig('foo.png',dpi=72)
works just fine (i.e., the file is correct and complete).

I'm puzzled since we are just using matplotlib commands, not any Sage commands. If we remove the "dpi=72" argument from savefig, everything works perfectly in all cases. My guess is that there is some sort of configuration option that Sage is setting when it starts up, but that is overridden or something after the first time matplotlib saves a figure. But I have no clue what sort of thing to look for. Does anyone have an idea of what could be causing this issue?

Thanks,

Jason

--
Jason Grout

<<inline: foo.png>>

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to