Ben: That's what I did: plt.show() then plt.savefig(). I now know to reverse the order. Thanks! - Roy
On Fri, Jul 29, 2011 at 6:19 PM, Roy Lowrance <email@example.com> wrote:
I'm using matplotlib on ubuntu 11.04.I create a figure and an axes and then show it via plt.show().From the window that plt.show() opens, I save the file to plot-3.png. This works as I can open the file with evince.However, when my program executes plt.savefig('plot-3.png'), something is saved as a file is created, but when I open the file with evince (or GIMP), I see just the canvas, not the figure.How do I save under program control?- Roy
There are a few common mistakes that might have happened. First, if you did a plt.show() and then closed the displayed figure, and *then* saved the figure, you will be saving the image of a new figure as you have already "destroyed" the old figure. If this is the case, put the savefig command *before* plt.show().
Another possibility is that another figure was somehow created between the last plotting
function and the call to savefig(). plt.savefig() assumes the current (active) figure, and so if another figure is accidentially created before calling savefig(), then you will be saving a blank figure.
I hope this helps, and let us know if you have further questions!