how can i raise the dpi without changing the dimensions of my picture?

Hi there, I make a figure, then I do some stuff, then I save the figure.

stuff
fig = figure(figsize = (0.75, 3.5))
stuff
fig.savefig(‘name.png’, bbox_inches='tight')

My figure is perfect, but I'm having trouble increasing the resolution.
There are two ways that I can figure out to do that, one is send a dpi as an
argument to figure() and the other to savefig(). Sending it to figure()
doesn’t change the file at all, so I'm not sure what it does, but sending it
to savefig() does change the file. When I send dpi to savefig(), like
dpi=500, the resolution seems to get much better, and the file size grows,
but the problem is that the height and width of the picture grows too. I
want the resolution to go up, but not the height and width of the picture.
What can I do?

Thanks!
Bradley

Let me see if I understand this right, you want to leave the image dimensions, in inches, constant while increasing the resolution in DPI to get a sharper image. Did I get that correct?

If you like the way the image appears on screen, use the DPI argument to savefig(). My experience is that if you change the DPI when creating the figure, that will change the layout.

What it sounds like you are seeing is that when you crank the DPI up, the PNG you created does not change its listed DPI, and displays larger. I checked on my system, matplotlib 1.1.1, and it is updating the DPI in the PNG files.

My question back to you is, why does it matter? Most layout programs will let you set the physical size of the figure and scale the DPI to match.

···

On Nov 16, 2013 3:06 PM, “Bradley Coleman” <colemanb@…4466…> wrote:

Hi there, I make a figure, then I do some stuff, then I save the figure.

stuff

fig = figure(figsize = (0.75, 3.5))

stuff

fig.savefig(‘name.png’, bbox_inches=‘tight’)

My figure is perfect, but I’m having trouble increasing the resolution.

There are two ways that I can figure out to do that, one is send a dpi as an

argument to figure() and the other to savefig(). Sending it to figure()

doesn’t change the file at all, so I’m not sure what it does, but sending it

to savefig() does change the file. When I send dpi to savefig(), like

dpi=500, the resolution seems to get much better, and the file size grows,

but the problem is that the height and width of the picture grows too. I

want the resolution to go up, but not the height and width of the picture.

What can I do?

Thanks!

Bradley


DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps

OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access

Free app hosting. Or install the open source package on any LAMP server.

Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!

http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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

See the discussion of pixel size at
http://wiki.scipy.org/Cookbook/Matplotlib/AdjustingImageSize

Alan Isaac