[Tutor] Spyder IDE Anaconda3: Problem with Plt.savefig

Alan Gauld alan.gauld at yahoo.co.uk
Wed Mar 1 20:32:58 EST 2017


On 01/03/17 20:20, Stephen P. Molnar wrote:
> I have written a Python3 program to plot and save UV/VIS spectra from 
> the results of an Orca quantum mechanical calculation.

Caveat: This forum is for help on the core Python language
and its standard library. Asking about anything beyond that
may require a lot more information about the context - for
example few of us will know anything about UV/VIS spectra
(even what that means!)

However, I'll hazard a guess...

> figure = name+'.png'
> print(figure)
> plt.savefig('figure', bbox_inches='tight')

Shouldn't the last line use the variable figure
rather than a literal string 'figure' :

plt.savefig(figure, bbox_inches='tight')

> where the print statement verifies the nae of the saved figure. The 
> problem is that the saved file is figure.png.

I'm guessing that's because you are passing the string 'figure'
instead of the variable.

But I don;t know anything about your plt object
or its savefig() method, not even which library
you are using. Is it matplotlib? Or something else?

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list