From: Bror J. <br...@bi...> - 2010-10-05 22:05:22
|
Dear all, I am trying to add a rectangle in a basemap map that reside in a inlined axis. I am basing this exercise on the following code: (from http://old.nabble.com/display-a-filled-lat-lon-basemap-rectangle.-td28169736.html) from matplotlib.patches import Polygon import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap map = Basemap(projection='moll',lon_0=0) x1,y1 = map(-10,-10) x2,y2 = map(-10,10) x3,y3 = map(10,10) x4,y4 = map(10,-10) p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],facecolor='red',edgecolor='blue',linewidth=2) plt.gca().add_patch(p) map.drawcoastlines() map.drawmapboundary() I can change the last part to: ax1 = plt.subplot(111) ax1.add_patch(p) map.ax = ax1 map.drawcoastlines() map.drawmapboundary() Which works fine. What I want is to create an extra axis for the map: ax1 = plt.subplot(111) ax2 = plt.axes([0.13,0.07,0.25,0.25]) ax2.add_patch(p) map.ax = ax2 map.drawcoastlines() map.drawmapboundary() The map is drawn correctly, but the patch doesn't show up. What am I doing wrong? Thanks for any help!!! :-)Bror |