fill entire figure area & DONT maintain aspect ratio

Hi,
I need help doing the following:

I need to create a square png image (256x256 pixels) with NO margins. I need my plot area to completely fill this 256x256 box, regardless of what the plot's aspect ratio should be; i.e., I want the plot area stretched or compressed either in the vertical or horizontal direction so that the plot completely fills png output...no margins at either the top&bottom or left&right edges.

The data Im plotting is geographic lat&lon ranges, and these areas are not perfectly square, they are more rectangular. matplotlib tries to maintain the aspect ratio in my plots and so it always adds margins to the top&bottom of my plot edges. I need to tell matplotlib to ignore the fact that the plot should be rectangular, and instead plot it to fit my figure size, even if this visually deforms my plot.

I understand that if I set the axes, I can somewhat control the margin size, so doing something like 'axes([0,0,1,1],frameon='false')' should eliminate the margins. I see that the axes() function has a 'set_aspect()' function, but Im not clear on how to use it, and Im even sure that it can do what I need it to do; 'disable' the aspect ratio and fill my figure area with my plot....

So, again, what can I do to completely fill the 2.56"x2.56" square figure ??? (even when the plot is NOT square, its rectangular...)

Please help,
P.Romero

···

_________________________________________________________________
Windows Live™ Groups: Create an online spot for your favorite groups to meet.
http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009

Pablo Romero wrote:

Hi,
I need help doing the following:
I need to create a square png image (256x256 pixels) with NO margins. I need my plot area to completely fill this 256x256 box, regardless of what the plot's aspect ratio should be; i.e., I want the plot area stretched or compressed either in the vertical or horizontal direction so that the plot completely fills png output...no margins at either the top&bottom or left&right edges.
The data Im plotting is geographic lat&lon ranges, and these areas are not perfectly square, they are more rectangular. matplotlib tries to maintain the aspect ratio in my plots and so it always adds margins to the top&bottom of my plot edges. I need to tell matplotlib to ignore the fact that the plot should be rectangular, and instead plot it to fit my figure size, even if this visually deforms my plot.

So, again, what can I do to completely fill the 2.56"x2.56" square figure ??? (even when the plot is NOT square, its rectangular...)

P.Romero
  
Pablo: If you are using basemap, the set_aspect method of the axes method is called automatically to force the aspect ratio of the map to be preserved. There is currently no way to override this, but it could be added if you really need it. I do wonder why you would want have a distorted map, just so it could be a certain pixel size? If you want a square map, why not just make your map a square region (in lat/lon coordinates)?

-Jeff