Dynamically defining map extents

Hello, I've defined the following function to dynamically define map extents
based on lon,lat input data. It is not very elegant or robust, but it does
seem to work. One issue, however, and it probably is related to something
else further down the chain... but every plot ends up being a different
size. So an improvement right off would be able to define a plot size (or at
least ratio, such that the limits would scale to the ratio). I would be
interested in comments on how to improve it.

def map_dynaMap((x,y)):
   """Sets a map region based on input data """

   ymin=min(y); ymax=max(y); y_edge=abs(ymax-ymin)*0.35
   xmin=min(x); xmax=max(x); x_edge=abs(xmax-xmin)*0.35

   llcrnrlat= ymin-y_edge
   if llcrnrlat<-90.: llcrnrlat=-90.
   llcrnrlon= xmin-x_edge
   if llcrnrlon<-180.: llcrnrlon=-180.
   urcrnrlat= ymax+y_edge
   if urcrnrlat>90.: urcrnrlat=90.
   urcrnrlon= xmax+x_edge
   if urcrnrlon>180.: urcrnrlon=180.
   area_thresh=1000
   resolution='l'
   projection='aea'
   lat_0=y[int(len(y)/2)]
   lat_1=lat_0-y_edge
   lon_0=x[int(len(x)/2)]
   #lon_1=110.
   rsphere=(6378137.00,6356752.3142)
   pd=y_edge
   md=x_edge
   return
urcrnrlon,urcrnrlat,llcrnrlat,llcrnrlon,pd,md,lat_0,lat_1,lon_0,area_thresh,projection,resolution,rsphere

···

--
View this message in context: http://www.nabble.com/Dynamically-defining-map-extents-tp17835230p17835230.html
Sent from the matplotlib - users mailing list archive at Nabble.com.