setting figure extent to only include extent of Axes

All: I have an issue I’m hoping someone here can help with. I’ve created a encapsulated postscript figure from pylab (basemap, actually, but it shouldn’t make a difference), and I’d like to have the entire saved image be the extent of the axes, with no border whatsoever. Is there a way to set the extent of either the axes or the figure so that this is so?

And before someone points this out to me - yes, I realize that there are other tools (ImageMagick, for example) I could use to trim the whitespace around the edge of the image, but this is part of an automated system and I’d prefer not to have to bomb out to a shell for something like that.

Thanks,

Mike

···

Michael Hearne

mhearne@…924…

(303) 273-8620

USGS National Earthquake Information Center

1711 Illinois St. Golden CO 80401

Senior Software Engineer

Synergetics, Inc.


Michael Hearne wrote:

All: I have an issue I'm hoping someone here can help with. I've created a encapsulated postscript figure from pylab (basemap, actually, but it shouldn't make a difference), and I'd like to have the entire saved image be the extent of the axes, with no border whatsoever. Is there a way to set the extent of either the axes or the figure so that this is so?

And before someone points this out to me - yes, I realize that there are other tools (ImageMagick, for example) I could use to trim the whitespace around the edge of the image, but this is part of an automated system and I'd prefer not to have to bomb out to a shell for something like that.

Thanks,

Mike

Mike: Create an axes instance (before drawing anything with your basemap instance) like this:

fig = pylab.figure(figsize=(X,Y))
ax = fig.add_axes([0,0,1,1])

X and Y need to be set to the desired width and height of your figure in inches. To avoid having any border, Y/X must be exactly equal to the aspect ratio of the map projection region (which you can get from the 'aspect' Basemap instance variable).

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

You can set the position of the axes with "set_position" and give it a list of the form [l, b, w, h], where the values range from 0 to 1. e.g.:

   gca().set_position([0, 0, 1, 1])

Cheers,
Mike

Michael Hearne wrote:

···

All: I have an issue I'm hoping someone here can help with. I've created a encapsulated postscript figure from pylab (basemap, actually, but it shouldn't make a difference), and I'd like to have the entire saved image be the extent of the axes, with no border whatsoever. Is there a way to set the extent of either the axes or the figure so that this is so?

And before someone points this out to me - yes, I realize that there are other tools (ImageMagick, for example) I could use to trim the whitespace around the edge of the image, but this is part of an automated system and I'd prefer not to have to bomb out to a shell for something like that.

Thanks,

Mike

------------------------------------------------------
Michael Hearne
mhearne@…924… <mailto:mhearne@…924…>
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------

------------------------------------------------------------------------

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA