hi all,
i'm trying to get the bounding box of a map plotted with basemap to place a
colorbar. in this reduced example from the example directory of basemap, the
colorbar is set to the hight of the axes of the plot.
from mpl_toolkits.basemap import Basemap, shiftgrid
import numpy as np
import matplotlib.pyplot as plt
topoin = np.loadtxt('etopo20data.gz')
lons = np.loadtxt('etopo20lons.gz')
lats = np.loadtxt('etopo20lats.gz')
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
m = Basemap(llcrnrlon=-57,llcrnrlat=37,urcrnrlon=-3,urcrnrlat=60,
resolution='i',projection='tmerc',lon_0=-41,lat_0=45)
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
# create the figure.
fig=plt.figure(figsize=(8,8))
# add an axes, leaving room for colorbar on the right.
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# associate this axes with the Basemap instance.
m.ax = ax
# plot image over map with imshow.
im = m.imshow(topodat,plt.cm.jet)
# setup colorbar axes instance.
pos = ax.get_position()
l, b, w, h = pos.bounds
cax = plt.axes([l+w+0.075, b, 0.05, h])
plt.colorbar(im,cax=cax) # draw colorbar
# plot blue dot on boulder, colorado and label it as such.
plt.show()
what i'm interested in is the bounding box of m, the real plotting area, so
i can scale the colorbar axes to that height or width.
is there a way to get this?
thanks in advance
mario
···
--
View this message in context: http://old.nabble.com/bbox-of-map-tp31974326p31974326.html
Sent from the matplotlib - users mailing list archive at Nabble.com.