8000 Convert hold-related functions to attribute assignments. by efiring · Pull Request #328 · matplotlib/basemap · GitHub
[go: up one dir, main page]

Skip to content

Convert hold-related functions to attribute assignments. #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
efiring committed Nov 27, 2016
commit 800e9aa2113f504aa4831493723777f16d418337
88 changes: 44 additions & 44 deletions lib/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3225,16 +3225,16 @@ def scatter(self, *args, **kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.scatter(*args, **kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt:
plt.sci(ret)
Expand Down Expand Up @@ -3263,16 +3263,16 @@ def plot(self, *args, **kwargs):
"""
ax = kwargs.pop('ax', None) or self._check_ax()
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.plot(*args, **kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# set axes limits to fit map region.
self.set_axes_limits(ax=ax)
# clip to map limbs
Expand All @@ -3299,16 +3299,16 @@ def imshow(self, *args, **kwargs):
if 'origin' not in kwargs:
kwargs['origin']='lower'
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.imshow(*args, **kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt:
plt.sci(ret)
Expand Down Expand Up @@ -3349,10 +3349,10 @@ def pcolor(self,x,y,data,**kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
if kwargs.pop('tri', False):
try:
Expand Down Expand Up @@ -3386,9 +3386,9 @@ def pcolor(self,x,y,data,**kwargs):
y = ma.masked_values(np.where(y > 1.e20,1.e20,y), 1.e20)
ret = ax.pcolor(x,y,data,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt:
plt.sci(ret)
Expand Down Expand Up @@ -3424,16 +3424,16 @@ def pcolormesh(self,x,y,data,**kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.pcolormesh(x,y,data,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt:
plt.sci(ret)
Expand Down Expand Up @@ -3470,20 +3470,20 @@ def hexbin(self,x,y,**kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
# make x,y masked arrays
# (masked where data is outside of projection limb)
x = ma.masked_values(np.where(x > 1.e20,1.e20,x), 1.e20)
y = ma.masked_values(np.where(y > 1.e20,1.e20,y), 1.e20)
ret = ax.hexbin(x,y,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt:
plt.sci(ret)
Expand Down Expand Up @@ -3516,10 +3516,10 @@ def contour(self,x,y,data,*args,**kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
if kwargs.pop('tri', False):
try:
Expand Down Expand Up @@ -3581,9 +3581,9 @@ def contour(self,x,y,data,*args,**kwargs):
data = ma.masked_array(data,mask=mask)
CS = ax.contour(x,y,data,*args,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt and CS.get_array() is not None:
plt.sci(CS)
Expand Down Expand Up @@ -3619,10 +3619,10 @@ def contourf(self,x,y,data,*args,**kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
if kwargs.get('tri', False):
try:
Expand Down Expand Up @@ -3686,9 +3686,9 @@ def contourf(self,x,y,data,*args,**kwargs):
data = ma.masked_array(data,mask=mask)
CS = ax.contourf(x,y,data,*args,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# reset current active image (only if pyplot is imported).
if plt and CS.get_array() is not None:
plt.sci(CS)
Expand Down Expand Up @@ -3718,16 +3718,16 @@ def quiver(self, x, y, u, v, *args, **kwargs):
"""
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.quiver(x,y,u,v,*args,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
if plt is not None and ret.get_array() is not None:
plt.sci(ret)
# set axes limits to fit map region.
Expand Down Expand Up @@ -3760,16 +3760,16 @@ def streamplot(self, x, y, u, v, *args, **kwargs):
raise NotImplementedError(msg)
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
try:
ret = ax.streamplot(x,y,u,v,*args,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
if plt is not None and ret.lines.get_array() is not None:
plt.sci(ret.lines)
# set axes limits to fit map region.
Expand Down Expand Up @@ -3810,10 +3810,10 @@ def barbs(self, x, y, u, v, *args, **kwargs):
raise NotImplementedError(msg)
ax, plt = self._ax_plt_from_kw(kwargs)
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
b = ax._hold
h = kwargs.pop('hold',None)
if h is not None:
ax.hold(h)
ax._hold = h
lons, lats = self(x, y, inverse=True)
unh = ma.masked_where(lats <= 0, u)
vnh = ma.masked_where(lats <= 0, v)
Expand All @@ -3824,9 +3824,9 @@ def barbs(self, x, y, u, v, *args, **kwargs):
kwargs['flip_barb']=True
retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs)
except:
ax.hold(b)
ax._hold = b
raise
ax.hold(b)
ax._hold = b
# Because there are two collections returned in general,
# we can't set the current image...
#if plt is not None and ret.get_array() is not None:
Expand Down
0