PIL + pyplot.savefig() size change

Hi,

I am new to matplotlib so I may not have found the right answer because I am looking in the wrong places.

I wrote a script to draw lines on a 800x600 pixels GIF background map. The output image I get is 620x450. Could someone let me know what I am doing wrong?

Code Snippet:

map = Basemap(......)
pilImg = Image.open('bkgmap.gif')
rgba = pil_to_array(pilImg)
map.imshow(rgba)
# Plot some lines and labels here
....
pyplot.savefig('outimg.png',format='PNG',bbox_inches='tight',pad_inches=0)

Thank you

The dpi value, which can be overridden, will determine the size of the
output image. It looks to me like you just want the output to always
be the same size as your input image, so use imsave() instead of
imshow() followed by savefig() for this:
i.e. just do

map = Basemap(......)
pilImg = Image.open('bkgmap.gif')
rgba = pil_to_array(pilImg)
pyplot.imsave('outimg.png', rgba)

ยทยทยท

On Fri, Sep 23, 2011 at 9:10 AM, Isidora <isidora@...3269...> wrote:

Hi,

I am new to matplotlib so I may not have found the right answer because I am looking in the wrong places.

I wrote a script to draw lines on a 800x600 pixels GIF background map. The output image I get is 620x450. Could someone let me know what I am doing wrong?

Code Snippet:

map = Basemap(......)
pilImg = Image.open('bkgmap.gif')
rgba = pil_to_array(pilImg)
map.imshow(rgba)
# Plot some lines and labels here
....
pyplot.savefig('outimg.png',format='PNG',bbox_inches='tight',pad_inches=0)

Thank you

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options