Skip to content

Commit c5a6c27

Browse files
author
Jeffrey Whitaker
committed
check to see if map boundary polygon is in current axes, if so don't redraw.
1 parent d3dc3f9 commit c5a6c27

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13301330
ax.set_frame_on(False)
13311331
# elliptical region.
13321332
ax.add_patch(limb)
1333+
self._mapboundarydrawn = limb
13331334
if fill_color is None:
13341335
limb.set_fill(False)
13351336
else:
@@ -1365,6 +1366,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13651366
xy = list(zip(x,y))
13661367
limb = Polygon(xy,edgecolor=color,linewidth=linewidth)
13671368
ax.add_patch(limb)
1369+
self._mapboundarydrawn = limb
13681370
if fill_color is None:
13691371
limb.set_fill(False)
13701372
else:
@@ -1378,6 +1380,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
13781380
limb = Circle((0.5*(self.xmax+self.xmin),0.5*(self.ymax+self.ymin)),
13791381
radius=0.5*(self.xmax-self.xmin),fc='none')
13801382
ax.add_patch(limb)
1383+
self._mapboundarydrawn = limb
13811384
if fill_color is None:
13821385
limb.set_fill(False)
13831386
else:
@@ -1430,6 +1433,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
14301433
# draw and fill map projection limb, clipped
14311434
# to rectangular region.
14321435
ax.add_patch(limb)
1436+
self._mapboundarydrawn = limb
14331437
if fill_color is None:
14341438
limb.set_fill(False)
14351439
else:
@@ -1441,7 +1445,6 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
14411445
limb.set_zorder(zorder)
14421446
limb.set_clip_on(True)
14431447
# set axes limits to fit map region.
1444-
self._mapboundarydrawn = True
14451448
self.set_axes_limits(ax=ax)
14461449
return limb
14471450

@@ -2819,19 +2822,20 @@ def set_axes_limits(self,ax=None):
28192822
ax.set_ylim((self.llcrnry, self.urcrnry))
28202823
# if map boundary not yet drawn, draw it with default values.
28212824
if not self._mapboundarydrawn:
2822-
# elliptical map, turn off axis_frame, draw boundary manually.
2823-
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2824-
self._fulldisk) or self.round or self.projection in _pseudocyl:
2825-
# turn off axes frame.
2826-
ax.set_frame_on(False)
2827-
# first draw boundary, no fill
2828-
limb1 = self.drawmapboundary(fill_color='none')
2829-
# draw another filled patch, with no boundary.
2830-
limb2 = self.drawmapboundary(linewidth=0)
2831-
self._mapboundarydrawn = True
2825+
# is the map boundary already drawn on the current axes?
2826+
if self._mapboundarydrawn not in ax.patches:
2827+
# elliptical map, turn off axis_frame, draw boundary manually.
2828+
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2829+
self._fulldisk) or self.round or self.projection in _pseudocyl:
2830+
# turn off axes frame.
2831+
ax.set_frame_on(False)
2832+
# first draw boundary, no fill
2833+
limb1 = self.drawmapboundary(fill_color='none')
2834+
# draw another filled patch, with no boundary.
2835+
limb2 = self.drawmapboundary(linewidth=0)
2836+
self._mapboundarydrawn = True
28322837
else: # square map, just turn on axis frame.
28332838
ax.set_frame_on(True)
2834-
self._mapboundarydrawn = True
28352839
# make sure aspect ratio of map preserved.
28362840
# plot is re-centered in bounding rectangle.
28372841
# (anchor instance var determines where plot is placed)

0 commit comments

Comments
 (0)