Skip to content

Commit 800e9aa

Browse files
committed
Convert hold-related functions to attribute assignments.
This is a minimal change so that the deprecation of "hold" in mpl 2.x won't trigger warnings in Basemap from routine plotting calls.
1 parent b80bfdc commit 800e9aa

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,16 +3225,16 @@ def scatter(self, *args, **kwargs):
32253225
"""
32263226
ax, plt = self._ax_plt_from_kw(kwargs)
32273227
# allow callers to override the hold state by passing hold=True|False
3228-
b = ax.ishold()
3228+
b = ax._hold
32293229
h = kwargs.pop('hold',None)
32303230
if h is not None:
3231-
ax.hold(h)
3231+
ax._hold = h
32323232
try:
32333233
ret = ax.scatter(*args, **kwargs)
32343234
except:
3235-
ax.hold(b)
3235+
ax._hold = b
32363236
raise
3237-
ax.hold(b)
3237+
ax._hold = b
32383238
# reset current active image (only if pyplot is imported).
32393239
if plt:
32403240
plt.sci(ret)
@@ -3263,16 +3263,16 @@ def plot(self, *args, **kwargs):
32633263
"""
32643264
ax = kwargs.pop('ax', None) or self._check_ax()
32653265
# allow callers to override the hold state by passing hold=True|False
3266-
b = ax.ishold()
3266+
b = ax._hold
32673267
h = kwargs.pop('hold',None)
32683268
if h is not None:
3269-
ax.hold(h)
3269+
ax._hold = h
32703270
try:
32713271
ret = ax.plot(*args, **kwargs)
32723272
except:
3273-
ax.hold(b)
3273+
ax._hold = b
32743274
raise
3275-
ax.hold(b)
3275+
ax._hold = b
32763276
# set axes limits to fit map region.
32773277
self.set_axes_limits(ax=ax)
32783278
# clip to map limbs
@@ -3299,16 +3299,16 @@ def imshow(self, *args, **kwargs):
32993299
if 'origin' not in kwargs:
33003300
kwargs['origin']='lower'
33013301
# allow callers to override the hold state by passing hold=True|False
3302-
b = ax.ishold()
3302+
b = ax._hold
33033303
h = kwargs.pop('hold',None)
33043304
if h is not None:
3305-
ax.hold(h)
3305+
ax._hold = h
33063306
try:
33073307
ret = ax.imshow(*args, **kwargs)
33083308
except:
3309-
ax.hold(b)
3309+
ax._hold = b
33103310
raise
3311-
ax.hold(b)
3311+
ax._hold = b
33123312
# reset current active image (only if pyplot is imported).
33133313
if plt:
33143314
plt.sci(ret)
@@ -3349,10 +3349,10 @@ def pcolor(self,x,y,data,**kwargs):
33493349
"""
33503350
ax, plt = self._ax_plt_from_kw(kwargs)
33513351
# allow callers to override the hold state by passing hold=True|False
3352-
b = ax.ishold()
3352+
b = ax._hold
33533353
h = kwargs.pop('hold',None)
33543354
if h is not None:
3355-
ax.hold(h)
3355+
ax._hold = h
33563356
try:
33573357
if kwargs.pop('tri', False):
33583358
try:
@@ -3386,9 +3386,9 @@ def pcolor(self,x,y,data,**kwargs):
33863386
y = ma.masked_values(np.where(y > 1.e20,1.e20,y), 1.e20)
33873387
ret = ax.pcolor(x,y,data,**kwargs)
33883388
except:
3389-
ax.hold(b)
3389+
ax._hold = b
33903390
raise
3391-
ax.hold(b)
3391+
ax._hold = b
33923392
# reset current active image (only if pyplot is imported).
33933393
if plt:
33943394
plt.sci(ret)
@@ -3424,16 +3424,16 @@ def pcolormesh(self,x,y,data,**kwargs):
34243424
"""
34253425
ax, plt = self._ax_plt_from_kw(kwargs)
34263426
# allow callers to override the hold state by passing hold=True|False
3427-
b = ax.ishold()
3427+
b = ax._hold
34283428
h = kwargs.pop('hold',None)
34293429
if h is not None:
3430-
ax.hold(h)
3430+
ax._hold = h
34313431
try:
34323432
ret = ax.pcolormesh(x,y,data,**kwargs)
34333433
except:
3434-
ax.hold(b)
3434+
ax._hold = b
34353435
raise
3436-
ax.hold(b)
3436+
ax._hold = b
34373437
# reset current active image (only if pyplot is imported).
34383438
if plt:
34393439
plt.sci(ret)
@@ -3470,20 +3470,20 @@ def hexbin(self,x,y,**kwargs):
34703470
"""
34713471
ax, plt = self._ax_plt_from_kw(kwargs)
34723472
# allow callers to override the hold state by passing hold=True|False
3473-
b = ax.ishold()
3473+
b = ax._hold
34743474
h = kwargs.pop('hold',None)
34753475
if h is not None:
3476-
ax.hold(h)
3476+
ax._hold = h
34773477
try:
34783478
# make x,y masked arrays
34793479
# (masked where data is outside of projection limb)
34803480
x = ma.masked_values(np.where(x > 1.e20,1.e20,x), 1.e20)
34813481
y = ma.masked_values(np.where(y > 1.e20,1.e20,y), 1.e20)
34823482
ret = ax.hexbin(x,y,**kwargs)
34833483
except:
3484-
ax.hold(b)
3484+
ax._hold = b
34853485
raise
3486-
ax.hold(b)
3486+
ax._hold = b
34873487
# reset current active image (only if pyplot is imported).
34883488
if plt:
34893489
plt.sci(ret)
@@ -3516,10 +3516,10 @@ def contour(self,x,y,data,*args,**kwargs):
35163516
"""
35173517
ax, plt = self._ax_plt_from_kw(kwargs)
35183518
# allow callers to override the hold state by passing hold=True|False
3519-
b = ax.ishold()
3519+
b = ax._hold
35203520
h = kwargs.pop('hold',None)
35213521
if h is not None:
3522-
ax.hold(h)
3522+
ax._hold = h
35233523
try:
35243524
if kwargs.pop('tri', False):
35253525
try:
@@ -3581,9 +3581,9 @@ def contour(self,x,y,data,*args,**kwargs):
35813581
data = ma.masked_array(data,mask=mask)
35823582
CS = ax.contour(x,y,data,*args,**kwargs)
35833583
except:
3584-
ax.hold(b)
3584+
ax._hold = b
35853585
raise
3586-
ax.hold(b)
3586+
ax._hold = b
35873587
# reset current active image (only if pyplot is imported).
35883588
if plt and CS.get_array() is not None:
35893589
plt.sci(CS)
@@ -3619,10 +3619,10 @@ def contourf(self,x,y,data,*args,**kwargs):
36193619
"""
36203620
ax, plt = self._ax_plt_from_kw(kwargs)
36213621
# allow callers to override the hold state by passing hold=True|False
3622-
b = ax.ishold()
3622+
b = ax._hold
36233623
h = kwargs.pop('hold',None)
36243624
if h is not None:
3625-
ax.hold(h)
3625+
ax._hold = h
36263626
try:
36273627
if kwargs.get('tri', False):
36283628
try:
@@ -3686,9 +3686,9 @@ def contourf(self,x,y,data,*args,**kwargs):
36863686
data = ma.masked_array(data,mask=mask)
36873687
CS = ax.contourf(x,y,data,*args,**kwargs)
36883688
except:
3689-
ax.hold(b)
3689+
ax._hold = b
36903690
raise
3691-
ax.hold(b)
3691+
ax._hold = b
36923692
# reset current active image (only if pyplot is imported).
36933693
if plt and CS.get_array() is not None:
36943694
plt.sci(CS)
@@ -3718,16 +3718,16 @@ def quiver(self, x, y, u, v, *args, **kwargs):
37183718
"""
37193719
ax, plt = self._ax_plt_from_kw(kwargs)
37203720
# allow callers to override the hold state by passing hold=True|False
3721-
b = ax.ishold()
3721+
b = ax._hold
37223722
h = kwargs.pop('hold',None)
37233723
if h is not None:
3724-
ax.hold(h)
3724+
ax._hold = h
37253725
try:
37263726
ret = ax.quiver(x,y,u,v,*args,**kwargs)
37273727
except:
3728-
ax.hold(b)
3728+
ax._hold = b
37293729
raise
3730-
ax.hold(b)
3730+
ax._hold = b
37313731
if plt is not None and ret.get_array() is not None:
37323732
plt.sci(ret)
37333733
# set axes limits to fit map region.
@@ -3760,16 +3760,16 @@ def streamplot(self, x, y, u, v, *args, **kwargs):
37603760
raise NotImplementedError(msg)
37613761
ax, plt = self._ax_plt_from_kw(kwargs)
37623762
# allow callers to override the hold state by passing hold=True|False
3763-
b = ax.ishold()
3763+
b = ax._hold
37643764
h = kwargs.pop('hold',None)
37653765
if h is not None:
3766-
ax.hold(h)
3766+
ax._hold = h
37673767
try:
37683768
ret = ax.streamplot(x,y,u,v,*args,**kwargs)
37693769
except:
3770-
ax.hold(b)
3770+
ax._hold = b
37713771
raise
3772-
ax.hold(b)
3772+
ax._hold = b
37733773
if plt is not None and ret.lines.get_array() is not None:
37743774
plt.sci(ret.lines)
37753775
# set axes limits to fit map region.
@@ -3810,10 +3810,10 @@ def barbs(self, x, y, u, v, *args, **kwargs):
38103810
raise NotImplementedError(msg)
38113811
ax, plt = self._ax_plt_from_kw(kwargs)
38123812
# allow callers to override the hold state by passing hold=True|False
3813-
b = ax.ishold()
3813+
b = ax._hold
38143814
h = kwargs.pop('hold',None)
38153815
if h is not None:
3816-
ax.hold(h)
3816+
ax._hold = h
38173817
lons, lats = self(x, y, inverse=True)
38183818
unh = ma.masked_where(lats <= 0, u)
38193819
vnh = ma.masked_where(lats <= 0, v)
@@ -3824,9 +3824,9 @@ def barbs(self, x, y, u, v, *args, **kwargs):
38243824
kwargs['flip_barb']=True
38253825
retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs)
38263826
except:
3827-
ax.hold(b)
3827+
ax._hold = b
38283828
raise
3829-
ax.hold(b)
3829+
ax._hold = b
38303830
# Because there are two collections returned in general,
38313831
# we can't set the current image...
38323832
#if plt is not None and ret.get_array() is not None:

0 commit comments

Comments
 (0)