How to tell savefig() image size in pixels

I browsed Google, and found mainly outdated code examples (also on scipy cookbook) then some 2008 posts on StackOverflow where at least I find some trace that matplotlib.figure.Figure has some instruments to change output image size, but it’s in combination from inches and dpi set. However I just couldn’t find how to tell my plt graph to use this matplotlib.figure.Figure settings, and ended editing matplotlibrc file and changing inches and DPI there

Shouldn’t be there some easier setting to set image size for savefig() output?

I’d also be interested if anyone has a suggestion for how to save a figure such that the pixel dimensions of a subplot (e.g. an image) are set.

···

On Sat, Jan 14, 2012 at 8:57 AM, klo uo <klonuo@…287…> wrote:

I browsed Google, and found mainly outdated code examples (also on scipy cookbook) then some 2008 posts on StackOverflow where at least I find some trace that matplotlib.figure.Figure has some instruments to change output image size, but it’s in combination from inches and dpi set. However I just couldn’t find how to tell my plt graph to use this matplotlib.figure.Figure settings, and ended editing matplotlibrc file and changing inches and DPI there

Shouldn’t be there some easier setting to set image size for savefig() output?


RSA(R) Conference 2012

Mar 27 - Feb 2

Save $400 by Jan. 27

Register now!

http://p.sf.net/sfu/rsa-sfdev2dev2


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

It’s a bit of a pain:

xPix = 900
yPix = 600

xSize = 3 #inches
ySize = xSize/xPix*yPix
gcf().set_inches_size(xSize,ySize)
gcf().savefig('test.png',dpi=xSize/xPix)

You can also chance pyplot.rcParams - it's a dictionary of default

values.

···

http://p.sf.net/sfu/learndevnow-d2dMatplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users