# specify resolution of saved graphic

 2 I can save a graphic I have created as a svg using the following command: p.save('/home/so10b.svg') However, my particular graphic is saved as a 39.5MB file, which is too large for my graphic editor to handle well. Saving as .ps creates a 20.4MB file. In the end, I want a .png, but with particular printed dimensions and resolution. So: What command will allow me to save a graphic in raster format with specific dimensions and resolution? asked Jul 18 '11 Bill 71 ● 1 ● 9

 2 I think that there are two options for plot() that can also be passed to save(). These are figsize in inches and dpi - the product of which (should) give the resolution of the image (although it doesn't seem to quite come out that way...). sage: p = plot(sin, (0, 2*pi)); p  sage: print p.SHOW_OPTIONS['figsize'], p.SHOW_OPTIONS['dpi'] (6, 3.7082039324993699) 100 sage: p.save(os.path.expanduser('~/sin.default.png')) sage: p.save(os.path.expanduser('~/sin.20.png'),dpi=20)  sin.default.png comes out at 506*316 pixels and 12.5KB, while sin.20.png is just 101*64 pixels and 1.8KB. Actually if you look at sage: print p.matplotlib() Figure(480x296.656)  This basically matches the size of the outputted png file once you remove the padding. posted Jul 19 '11 Simon 285 ● 2 ● 7 ● 18 http://www.physics.uwa.ed... OK. I tried using this command: p.save('/home/bill/demo2.png', xmin=-10, xmax=50, ymin=-10, ymax=30, aspect_ratio=1, axes=False, transparent=True, figsize=(12,8), dpi=300) Bill (Jul 19 '11) The image I get is 2850x1919, which at 300dpi is 9.5in x 6.4in, not 12x8. What's going on here? Bill (Jul 19 '11)@Bill: Yeah, as I said - it doesn't quite work the way it should... I'm not sure why. I'm not an expert on sage graphics nor matplotlib, so it might take a lot of digging in the code to track down what's going on. Simon (Jul 19 '11)@Simon Thanks for your help! Bill (Jul 19 '11) see 1 more comment

[hide preview]