Subaxis -> Basemap -> Rectangle

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§

map.drawcoastlines()

map.drawmapboundary()

I can change the last part to:

ax1 = plt.subplot(111)

ax1.add_patch§

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§

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 Jonsson

···

=============================================================

Post Doctoral Research Associate

Princeton University

Department of Geosciences

113 Guyot Hall

Princeton, NJ 08544-1003

USA

AIM, Skype, gTalk: brorfred

Phone: +1-617-818-1096

Nothing, AFAICT. Works here with matplotlib 1.0.0 and basemap 1.0.

-Jeff
···

On 10/5/10 7:14 PM, Bror Jonsson wrote:

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§

map.drawcoastlines()

            map.drawmapboundary()
          I can

change the last part to:

          ax1 =

plt.subplot(111)

ax1.add_patch§

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§

map.ax
= ax2

map.drawcoastlines()

map.drawmapboundary()

          The

map is drawn correctly, but the patch doesn’t show up.
What am I doing wrong?