diff --git a/boilerplate.py b/boilerplate.py index 1e7715160be7..5aab3b0af9da 100644 --- a/boilerplate.py +++ b/boilerplate.py @@ -50,15 +50,19 @@ @_autogen_docstring(Axes.%(func)s) def %(func)s(%(argspec)s): %(ax)s = gca() - # allow callers to override the hold state by passing hold=True|False - %(washold)s = %(ax)s.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + %(washold)s = %(ax)s._hold %(sethold)s if hold is not None: - %(ax)s.hold(hold) + %(ax)s._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: %(ret)s = %(ax)s.%(func)s(%(call)s) finally: - %(ax)s.hold(%(washold)s) + %(ax)s._hold = %(washold)s %(mappable)s return %(ret)s """ diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index a280df72bbc2..357518b8cf36 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -22,7 +22,6 @@ Color of Axes The ``axisbg`` and ``axis_bgcolor`` properties on ``Axes`` have been deprecated in favor of ``facecolor``. - GTK and GDK backends deprecated ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The GDK and GTK backends have been deprecated. These obsolete backends @@ -41,6 +40,16 @@ CocoaAgg backend removed ~~~~~~~~~~~~~~~~~~~~~~~~ The deprecated and not fully functional CocoaAgg backend has been removed. +'hold' functionality deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The 'hold' keyword argument and all functions and methods related +to it are deprecated, along with the 'axes.hold' `rcParams` entry. +The behavior will remain consistent with the default ``hold=True`` +state that has long been in place. Instead of using a function +or keyword argument (``hold=False``) to change that behavior, +explicitly clear the axes or figure as needed prior to subsequent +plotting commands. + `Artist.update` has return value -------------------------------- diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 7c792bd0c160..f18b6bd337df 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -870,8 +870,13 @@ def matplotlib_fname(): } _obsolete_set = set(['tk.pythoninspect', 'legend.isaxes']) + +# The following may use a value of None to suppress the warning. +_deprecated_set = set(['axes.hold']) # do NOT include in _all_deprecated + _all_deprecated = set(chain(_deprecated_ignore_map, - _deprecated_map, _obsolete_set)) + _deprecated_map, + _obsolete_set)) class RcParams(dict): @@ -887,6 +892,8 @@ class RcParams(dict): six.iteritems(defaultParams) if key not in _all_deprecated) msg_depr = "%s is deprecated and replaced with %s; please use the latter." + msg_depr_set = ("%s is deprecated. Please remove it from your " + "matplotlibrc and/or style files.") msg_depr_ignore = "%s is deprecated and ignored. Use %s" msg_obsolete = ("%s is obsolete. Please remove it from your matplotlibrc " "and/or style files.") @@ -903,6 +910,8 @@ def __setitem__(self, key, val): warnings.warn(self.msg_depr % (key, alt_key)) key = alt_key val = alt_val(val) + elif key in _deprecated_set and val is not None: + warnings.warn(self.msg_depr_set % key) elif key in _deprecated_ignore_map: alt = _deprecated_ignore_map[key] warnings.warn(self.msg_depr_ignore % (key, alt)) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9ca85f8b052c..7becdb4e8baa 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1665,7 +1665,7 @@ def acorr(self, x, **kwargs): x : sequence of scalar - hold : boolean, optional, default: True + hold : boolean, optional, *deprecated*, default: True detrend : callable, optional, default: `mlab.detrend_none` x is detrended by the `detrend` callable. Default is no @@ -1713,6 +1713,8 @@ def acorr(self, x, **kwargs): .. plot:: mpl_examples/pylab_examples/xcorr_demo.py """ + if "hold" in kwargs: + warnings.warn("the 'hold' kwarg is deprecated", mplDeprecation) return self.xcorr(x, x, **kwargs) @unpack_labeled_data(replace_names=["x", "y"], label_namer="y") @@ -1730,7 +1732,7 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, y : sequence of scalars of length n - hold : boolean, optional, default: True + hold : boolean, optional, *deprecated*, default: True detrend : callable, optional, default: `mlab.detrend_none` x is detrended by the `detrend` callable. Default is no @@ -1769,6 +1771,8 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, The cross correlation is performed with :func:`numpy.correlate` with `mode` = 2. """ + if "hold" in kwargs: + warnings.warn("the 'hold' kwarg is deprecated", mplDeprecation) Nx = len(x) if Nx != len(y): @@ -2136,7 +2140,7 @@ def make_iterable(x): patches.append(r) holdstate = self._hold - self.hold(True) # ensure hold is on before plotting errorbars + self._hold = True # ensure hold is on before plotting errorbars if xerr is not None or yerr is not None: if orientation == 'vertical': @@ -2158,7 +2162,7 @@ def make_iterable(x): else: errorbar = None - self.hold(holdstate) # restore previous hold state + self._hold = holdstate # restore previous hold state if adjust_xlim: xmin, xmax = self.dataLim.intervalx @@ -2380,7 +2384,7 @@ def stem(self, *args, **kwargs): remember_hold = self._hold if not self._hold: self.cla() - self.hold(True) + self._hold = True # Assume there's at least one data array y = np.asarray(args[0]) @@ -2464,7 +2468,7 @@ def stem(self, *args, **kwargs): color=basecolor, linestyle=basestyle, marker=basemarker, label="_nolegend_") - self.hold(remember_hold) + self._hold = remember_hold stem_container = StemContainer((markerline, stemlines, baseline), label=label) @@ -3786,7 +3790,7 @@ def dopatch(xs, ys, **kwargs): setlabels(datalabels) # reset hold status - self.hold(holdStatus) + self._hold = holdStatus return dict(whiskers=whiskers, caps=caps, boxes=boxes, medians=medians, fliers=fliers, means=means) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 95a052461ac4..1e4c3e8d5f40 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -540,6 +540,9 @@ def __init__(self, fig, rect, self._rasterization_zorder = None self._hold = rcParams['axes.hold'] + if self._hold is None: + self._hold = True + self._connected = {} # a dict from events to (id, func) self.cla() # funcs used to format x and y - fall back on major formatters @@ -1191,14 +1194,25 @@ def set_color_cycle(self, clist): else: self.set_prop_cycle('color', clist) + @cbook.deprecated("2.0") def ishold(self): - """return the HOLD status of the axes""" + """return the HOLD status of the axes + + The `hold` mechanism is deprecated and will be removed in + v3.0. + """ + return self._hold + @cbook.deprecated("2.0") def hold(self, b=None): """ Set the hold state + The ``hold`` mechanism is deprecated and will be removed in + v3.0. The behavior will remain consistent with the + long-time default value of True. + If *hold* is *None* (default), toggle the *hold* state. Else set the *hold* state to boolean value *b*. diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index a7c6c97249fe..a285d2b1a92c 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -501,10 +501,10 @@ def _add_solids(self, X, Y, C): # Save, set, and restore hold state to keep pcolor from # clearing the axes. Ordinarily this will not be needed, # since the axes object should already have hold set. - _hold = self.ax.ishold() - self.ax.hold(True) + _hold = self.ax._hold + self.ax._hold = True col = self.ax.pcolormesh(*args, **kw) - self.ax.hold(_hold) + self.ax._hold = _hold #self.add_observer(col) # We should observe, not be observed... if self.solids is not None: @@ -1262,8 +1262,8 @@ def _add_solids(self, X, Y, C): # Save, set, and restore hold state to keep pcolor from # clearing the axes. Ordinarily this will not be needed, # since the axes object should already have hold set. - _hold = self.ax.ishold() - self.ax.hold(True) + _hold = self.ax._hold + self.ax._hold = True kw = {'alpha': self.alpha, } @@ -1309,7 +1309,7 @@ def _add_solids(self, X, Y, C): linewidths=(0.5 * mpl.rcParams['axes.linewidth'],)) self.ax.add_collection(self.dividers) - self.ax.hold(_hold) + self.ax._hold = _hold def colorbar_factory(cax, mappable, **kwargs): diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 6cc3178dd381..030d50263d87 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -342,6 +342,9 @@ def __init__(self, self.patch.set_aa(False) self._hold = rcParams['axes.hold'] + if self._hold is None: + self._hold = True + self.canvas = None self._suptitle = None @@ -569,6 +572,7 @@ def set_canvas(self, canvas): """ self.canvas = canvas + @cbook.deprecated("2.0") def hold(self, b=None): """ Set the hold state. If hold is None (default), toggle the @@ -579,6 +583,8 @@ def hold(self, b=None): hold() # toggle hold hold(True) # hold is on hold(False) # hold is off + + All "hold" machinery is deprecated. """ if b is None: self._hold = not self._hold @@ -1591,7 +1597,7 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw): cax, kw = cbar.make_axes_gridspec(ax, **kw) else: cax, kw = cbar.make_axes(ax, **kw) - cax.hold(True) + cax._hold = True cb = cbar.colorbar_factory(cax, mappable, **kw) self.sca(current_ax) diff --git a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle index ba51f408035e..02e08fa7f93e 100644 --- a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle @@ -174,7 +174,6 @@ mathtext.default : it # The default font to use for math. # default face and edge color, default tick sizes, # default fontsizes for ticklabels, and so on. See # http://matplotlib.org/api/axes_api.html#module-matplotlib.axes -axes.hold : True # whether to clear the axes by default on axes.facecolor : w # axes background color axes.edgecolor : k # axes edge color axes.linewidth : 1.0 # edge linewidth diff --git a/lib/matplotlib/pylab.py b/lib/matplotlib/pylab.py index a3124c212986..df22eefda981 100644 --- a/lib/matplotlib/pylab.py +++ b/lib/matplotlib/pylab.py @@ -49,14 +49,12 @@ getp - get a graphics property grid - set whether gridding is on hist - make a histogram - hold - set the axes hold state ioff - turn interaction mode off ion - turn interaction mode on isinteractive - return True if interaction mode is on imread - load image file into array imsave - save array as an image file imshow - plot image data - ishold - return the hold state of the current axes legend - make an axes legend locator_params - adjust parameters used in locating axis ticks loglog - a log log plot diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 6adbe85a1ab5..d9b6a2a309c2 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -31,6 +31,7 @@ from matplotlib import _pylab_helpers, interactive from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike from matplotlib.cbook import _string_to_bool +from matplotlib.cbook import deprecated from matplotlib import docstring from matplotlib.backend_bases import FigureCanvasBase from matplotlib.figure import Figure, figaspect @@ -737,11 +738,8 @@ def suptitle(*args, **kwargs): return gcf().suptitle(*args, **kwargs) -@docstring.Appender("Addition kwargs: hold = [True|False] overrides default hold state", "\n") @docstring.copy_dedent(Figure.figimage) def figimage(*args, **kwargs): - # allow callers to override the hold state by passing hold=True|False - #sci(ret) # JDH figimage should not set current image -- it is not mappable, etc return gcf().figimage(*args, **kwargs) @@ -778,6 +776,11 @@ def figlegend(handles, labels, loc, **kwargs): ## Figure and Axes hybrid ## +_hold_msg = """Future behavior will be consistent with the long-time + default: plot commands add elements without first + clearing the Axes and/or Figure.""" + +@deprecated("2.0", message=_hold_msg) def hold(b=None): """ Set the hold state. If *b* is None (default), toggle the @@ -787,32 +790,40 @@ def hold(b=None): hold(True) # hold is on hold(False) # hold is off - When *hold* is *True*, subsequent plot commands will be added to + When *hold* is *True*, subsequent plot commands will add elements to the current axes. When *hold* is *False*, the current axes and figure will be cleared on the next plot command. + """ fig = gcf() ax = fig.gca() - fig.hold(b) - ax.hold(b) + if b is not None: + b = bool(b) + fig._hold = b + ax._hold = b # b=None toggles the hold state, so let's get get the current hold # state; but should pyplot hold toggle the rc setting - me thinks # not - b = ax.ishold() + b = ax._hold + # The comment above looks ancient; and probably the line below, + # contrary to the comment, is equally ancient. It will trigger + # a second warning, but "Oh, well...". rc('axes', hold=b) - +@deprecated("2.0", message=_hold_msg) def ishold(): """ Return the hold status of the current axes. + """ - return gca().ishold() + return gca()._hold +@deprecated("2.0", message=_hold_msg) def over(func, *args, **kwargs): """ Call a function with hold(True). @@ -822,11 +833,13 @@ def over(func, *args, **kwargs): func(*args, **kwargs) with ``hold(True)`` and then restores the hold state. + """ - h = ishold() - hold(True) + ax = gca() + h = ax._hold + ax._hold = True func(*args, **kwargs) - hold(h) + ax._hold = h ## Axes ## @@ -2486,24 +2499,29 @@ def getname_val(identifier): def _autogen_docstring(base): """Autogenerated wrappers will get their docstring from a base function with an addendum.""" - msg = "\n\nAdditional kwargs: hold = [True|False] overrides default hold state" + #msg = "\n\nAdditional kwargs: hold = [True|False] overrides default hold state" + msg = '' addendum = docstring.Appender(msg, '\n\n') return lambda func: addendum(docstring.copy_dedent(base)(func)) # This function cannot be generated by boilerplate.py because it may # return an image or a line. @_autogen_docstring(Axes.spy) -def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, **kwargs): +def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs): ax = gca() + hold = kwargs.pop('hold', None) # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.spy(Z, precision, marker, markersize, aspect, **kwargs) finally: - ax.hold(washold) + ax._hold = washold if isinstance(ret, cm.ScalarMappable): sci(ret) return ret @@ -2523,15 +2541,19 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None, @_autogen_docstring(Axes.acorr) def acorr(x, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.acorr(x, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2541,16 +2563,20 @@ def acorr(x, hold=None, data=None, **kwargs): def angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.angle_spectrum(x, Fs=Fs, Fc=Fc, window=window, pad_to=pad_to, sides=sides, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2559,15 +2585,19 @@ def angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, @_autogen_docstring(Axes.arrow) def arrow(x, y, dx, dy, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.arrow(x, y, dx, dy, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2576,15 +2606,19 @@ def arrow(x, y, dx, dy, hold=None, **kwargs): @_autogen_docstring(Axes.axhline) def axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.axhline(y=y, xmin=xmin, xmax=xmax, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2593,15 +2627,19 @@ def axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs): @_autogen_docstring(Axes.axhspan) def axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.axhspan(ymin, ymax, xmin=xmin, xmax=xmax, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2610,15 +2648,19 @@ def axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs): @_autogen_docstring(Axes.axvline) def axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.axvline(x=x, ymin=ymin, ymax=ymax, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2627,15 +2669,19 @@ def axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs): @_autogen_docstring(Axes.axvspan) def axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2644,16 +2690,20 @@ def axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs): @_autogen_docstring(Axes.bar) def bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.bar(left, height, width=width, bottom=bottom, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2662,15 +2712,19 @@ def bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs): @_autogen_docstring(Axes.barh) def barh(bottom, width, height=0.8, left=None, hold=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.barh(bottom, width, height=height, left=left, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2679,15 +2733,19 @@ def barh(bottom, width, height=0.8, left=None, hold=None, **kwargs): @_autogen_docstring(Axes.broken_barh) def broken_barh(xranges, yrange, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.broken_barh(xranges, yrange, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2702,11 +2760,15 @@ def boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, whiskerprops=None, manage_xticks=True, autorange=False, zorder=None, hold=None, data=None): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.boxplot(x, notch=notch, sym=sym, vert=vert, whis=whis, positions=positions, widths=widths, @@ -2722,7 +2784,7 @@ def boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, manage_xticks=manage_xticks, autorange=autorange, zorder=zorder, data=data) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2733,18 +2795,22 @@ def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.cohere(x, y, NFFT=NFFT, Fs=Fs, Fc=Fc, detrend=detrend, window=window, noverlap=noverlap, pad_to=pad_to, sides=sides, scale_by_freq=scale_by_freq, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2753,15 +2819,19 @@ def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, @_autogen_docstring(Axes.clabel) def clabel(CS, *args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.clabel(CS, *args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2770,15 +2840,19 @@ def clabel(CS, *args, **kwargs): @_autogen_docstring(Axes.contour) def contour(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.contour(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold if ret._A is not None: sci(ret) return ret @@ -2787,15 +2861,19 @@ def contour(*args, **kwargs): @_autogen_docstring(Axes.contourf) def contourf(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.contourf(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold if ret._A is not None: sci(ret) return ret @@ -2806,18 +2884,22 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, return_line=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.csd(x, y, NFFT=NFFT, Fs=Fs, Fc=Fc, detrend=detrend, window=window, noverlap=noverlap, pad_to=pad_to, sides=sides, scale_by_freq=scale_by_freq, return_line=return_line, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2829,11 +2911,15 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None, xlolims=False, xuplims=False, errorevery=1, capthick=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.errorbar(x, y, yerr=yerr, xerr=xerr, fmt=fmt, ecolor=ecolor, elinewidth=elinewidth, capsize=capsize, @@ -2842,7 +2928,7 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None, errorevery=errorevery, capthick=capthick, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2853,18 +2939,22 @@ def eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1, linewidths=None, colors=None, linestyles='solid', hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.eventplot(positions, orientation=orientation, lineoffsets=lineoffsets, linelengths=linelengths, linewidths=linewidths, colors=colors, linestyles=linestyles, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2873,15 +2963,19 @@ def eventplot(positions, orientation='horizontal', lineoffsets=1, linelengths=1, @_autogen_docstring(Axes.fill) def fill(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.fill(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2891,17 +2985,21 @@ def fill(*args, **kwargs): def fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.fill_between(x, y1, y2=y2, where=where, interpolate=interpolate, step=step, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2911,16 +3009,20 @@ def fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, def fill_betweenx(y, x1, x2=0, where=None, step=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.fill_betweenx(y, x1, x2=x2, where=where, step=step, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2933,11 +3035,15 @@ def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', reduce_C_function=np.mean, mincnt=None, marginals=False, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.hexbin(x, y, C=C, gridsize=gridsize, bins=bins, xscale=xscale, yscale=yscale, extent=extent, cmap=cmap, norm=norm, @@ -2946,7 +3052,7 @@ def hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', reduce_C_function=reduce_C_function, mincnt=mincnt, marginals=marginals, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -2958,11 +3064,15 @@ def hist(x, bins=None, range=None, normed=False, weights=None, cumulative=False, rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.hist(x, bins=bins, range=range, normed=normed, weights=weights, cumulative=cumulative, bottom=bottom, @@ -2970,7 +3080,7 @@ def hist(x, bins=None, range=None, normed=False, weights=None, cumulative=False, rwidth=rwidth, log=log, color=color, label=label, stacked=stacked, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -2980,17 +3090,21 @@ def hist(x, bins=None, range=None, normed=False, weights=None, cumulative=False, def hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None, cmax=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.hist2d(x, y, bins=bins, range=range, normed=normed, weights=weights, cmin=cmin, cmax=cmax, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret[-1]) return ret @@ -3000,16 +3114,20 @@ def hist2d(x, y, bins=10, range=None, normed=False, weights=None, cmin=None, def hlines(y, xmin, xmax, colors='k', linestyles='solid', label='', hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.hlines(y, xmin, xmax, colors=colors, linestyles=linestyles, label=label, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3021,11 +3139,15 @@ def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.imshow(X, cmap=cmap, norm=norm, aspect=aspect, interpolation=interpolation, alpha=alpha, vmin=vmin, @@ -3034,7 +3156,7 @@ def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, imlim=imlim, resample=resample, url=url, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3043,15 +3165,19 @@ def imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, @_autogen_docstring(Axes.loglog) def loglog(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.loglog(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3061,17 +3187,21 @@ def loglog(*args, **kwargs): def magnitude_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, scale=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.magnitude_spectrum(x, Fs=Fs, Fc=Fc, window=window, pad_to=pad_to, sides=sides, scale=scale, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3080,15 +3210,19 @@ def magnitude_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, @_autogen_docstring(Axes.pcolor) def pcolor(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.pcolor(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3097,15 +3231,19 @@ def pcolor(*args, **kwargs): @_autogen_docstring(Axes.pcolormesh) def pcolormesh(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.pcolormesh(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3115,16 +3253,20 @@ def pcolormesh(*args, **kwargs): def phase_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.phase_spectrum(x, Fs=Fs, Fc=Fc, window=window, pad_to=pad_to, sides=sides, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3136,11 +3278,15 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None, radius=None, counterclock=True, wedgeprops=None, textprops=None, center=(0, 0), frame=False, hold=None, data=None): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.pie(x, explode=explode, labels=labels, colors=colors, autopct=autopct, pctdistance=pctdistance, shadow=shadow, @@ -3149,7 +3295,7 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None, wedgeprops=wedgeprops, textprops=textprops, center=center, frame=frame, data=data) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3158,15 +3304,19 @@ def pie(x, explode=None, labels=None, colors=None, autopct=None, @_autogen_docstring(Axes.plot) def plot(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.plot(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3176,16 +3326,20 @@ def plot(*args, **kwargs): def plot_date(x, y, fmt='o', tz=None, xdate=True, ydate=False, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.plot_date(x, y, fmt=fmt, tz=tz, xdate=xdate, ydate=ydate, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3196,18 +3350,22 @@ def psd(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, return_line=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.psd(x, NFFT=NFFT, Fs=Fs, Fc=Fc, detrend=detrend, window=window, noverlap=noverlap, pad_to=pad_to, sides=sides, scale_by_freq=scale_by_freq, return_line=return_line, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3216,15 +3374,19 @@ def psd(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, @_autogen_docstring(Axes.quiver) def quiver(*args, **kw): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kw.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.quiver(*args, **kw) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3233,15 +3395,19 @@ def quiver(*args, **kw): @_autogen_docstring(Axes.quiverkey) def quiverkey(*args, **kw): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kw.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.quiverkey(*args, **kw) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3252,18 +3418,22 @@ def scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.scatter(x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm, vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths, verts=verts, edgecolors=edgecolors, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3272,15 +3442,19 @@ def scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, @_autogen_docstring(Axes.semilogx) def semilogx(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.semilogx(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3289,15 +3463,19 @@ def semilogx(*args, **kwargs): @_autogen_docstring(Axes.semilogy) def semilogy(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.semilogy(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3309,11 +3487,15 @@ def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, scale_by_freq=None, mode=None, scale=None, vmin=None, vmax=None, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.specgram(x, NFFT=NFFT, Fs=Fs, Fc=Fc, detrend=detrend, window=window, noverlap=noverlap, cmap=cmap, @@ -3321,7 +3503,7 @@ def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, scale_by_freq=scale_by_freq, mode=mode, scale=scale, vmin=vmin, vmax=vmax, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret[-1]) return ret @@ -3330,15 +3512,19 @@ def specgram(x, NFFT=None, Fs=None, Fc=None, detrend=None, window=None, @_autogen_docstring(Axes.stackplot) def stackplot(x, *args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.stackplot(x, *args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3347,15 +3533,19 @@ def stackplot(x, *args, **kwargs): @_autogen_docstring(Axes.stem) def stem(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.stem(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3364,15 +3554,19 @@ def stem(*args, **kwargs): @_autogen_docstring(Axes.step) def step(x, y, *args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.step(x, y, *args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3384,11 +3578,15 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None, transform=None, zorder=None, start_points=None, hold=None, data=None): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.streamplot(x, y, u, v, density=density, linewidth=linewidth, color=color, cmap=cmap, norm=norm, @@ -3396,7 +3594,7 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None, minlength=minlength, transform=transform, zorder=zorder, start_points=start_points, data=data) finally: - ax.hold(washold) + ax._hold = washold sci(ret.lines) return ret @@ -3405,15 +3603,19 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None, @_autogen_docstring(Axes.tricontour) def tricontour(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.tricontour(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold if ret._A is not None: sci(ret) return ret @@ -3422,15 +3624,19 @@ def tricontour(*args, **kwargs): @_autogen_docstring(Axes.tricontourf) def tricontourf(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.tricontourf(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold if ret._A is not None: sci(ret) return ret @@ -3439,15 +3645,19 @@ def tricontourf(*args, **kwargs): @_autogen_docstring(Axes.tripcolor) def tripcolor(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.tripcolor(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold sci(ret) return ret @@ -3456,15 +3666,19 @@ def tripcolor(*args, **kwargs): @_autogen_docstring(Axes.triplot) def triplot(*args, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kwargs.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.triplot(*args, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3475,18 +3689,22 @@ def violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False, showextrema=True, showmedians=False, points=100, bw_method=None, hold=None, data=None): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.violinplot(dataset, positions=positions, vert=vert, widths=widths, showmeans=showmeans, showextrema=showextrema, showmedians=showmedians, points=points, bw_method=bw_method, data=data) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3496,16 +3714,20 @@ def violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False, def vlines(x, ymin, ymax, colors='k', linestyles='solid', label='', hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.vlines(x, ymin, ymax, colors=colors, linestyles=linestyles, label=label, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3515,17 +3737,21 @@ def vlines(x, ymin, ymax, colors='k', linestyles='solid', label='', hold=None, def xcorr(x, y, normed=True, detrend=mlab.detrend_none, usevlines=True, maxlags=10, hold=None, data=None, **kwargs): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.xcorr(x, y, normed=normed, detrend=detrend, usevlines=usevlines, maxlags=maxlags, data=data, **kwargs) finally: - ax.hold(washold) + ax._hold = washold return ret @@ -3534,15 +3760,19 @@ def xcorr(x, y, normed=True, detrend=mlab.detrend_none, usevlines=True, @_autogen_docstring(Axes.barbs) def barbs(*args, **kw): ax = gca() - # allow callers to override the hold state by passing hold=True|False - washold = ax.ishold() + # Deprecated: allow callers to override the hold state + # by passing hold=True|False + washold = ax._hold hold = kw.pop('hold', None) if hold is not None: - ax.hold(hold) + ax._hold = hold + from matplotlib.cbook import mplDeprecation + warnings.warn("The 'hold' keyword argument is deprecated since 2.0.", + mplDeprecation) try: ret = ax.barbs(*args, **kw) finally: - ax.hold(washold) + ax._hold = washold return ret diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index c338873723c9..517b370c347f 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -145,6 +145,14 @@ def validate_bool_maybe_none(b): raise ValueError('Could not convert "%s" to boolean' % b) +def deprecate_axes_hold(value): + if value is None: + return None # converted to True where accessed in figure.py, + # axes/_base.py + warnings.warn("axes.hold is deprecated, will be removed in 3.0") + return validate_bool(value) + + def validate_float(s): """convert s to float or raise""" try: @@ -1053,7 +1061,7 @@ def validate_animation_writer_path(p): # axes props 'axes.axisbelow': ['line', validate_axisbelow], - 'axes.hold': [True, validate_bool], + 'axes.hold': [None, deprecate_axes_hold], 'axes.facecolor': ['w', validate_color], # background color; white 'axes.edgecolor': ['k', validate_color], # edge color; black 'axes.linewidth': [0.8, validate_float], # edge linewidth diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 58c57448daac..2e70be4e7995 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3205,10 +3205,6 @@ def test_specgram_angle_freqs(): ax12 = fig1.add_subplot(3, 1, 2) ax13 = fig1.add_subplot(3, 1, 3) - ax11.hold(True) - ax12.hold(True) - ax13.hold(True) - spec11 = ax11.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, pad_to=pad_to, sides='default', mode='angle') spec12 = ax12.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, @@ -3253,10 +3249,6 @@ def test_specgram_noise_angle(): ax12 = fig1.add_subplot(3, 1, 2) ax13 = fig1.add_subplot(3, 1, 3) - ax11.hold(True) - ax12.hold(True) - ax13.hold(True) - spec11 = ax11.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, pad_to=pad_to, sides='default', mode='angle') spec12 = ax12.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, @@ -3309,10 +3301,6 @@ def test_specgram_freqs_phase(): ax12 = fig1.add_subplot(3, 1, 2) ax13 = fig1.add_subplot(3, 1, 3) - ax11.hold(True) - ax12.hold(True) - ax13.hold(True) - spec11 = ax11.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, pad_to=pad_to, sides='default', mode='phase') spec12 = ax12.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, @@ -3357,10 +3345,6 @@ def test_specgram_noise_phase(): ax12 = fig1.add_subplot(3, 1, 2) ax13 = fig1.add_subplot(3, 1, 3) - ax11.hold(True) - ax12.hold(True) - ax13.hold(True) - spec11 = ax11.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap, pad_to=pad_to, sides='default', mode='phase', ) diff --git a/lib/mpl_toolkits/axes_grid1/axes_grid.py b/lib/mpl_toolkits/axes_grid1/axes_grid.py index b331ec0d0062..b8cc8c4fbc9a 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_grid.py +++ b/lib/mpl_toolkits/axes_grid1/axes_grid.py @@ -89,7 +89,7 @@ def colorbar(self, mappable, **kwargs): else: kwargs["ticks"] = locator - self.hold(True) + self._hold = True if self.orientation in ["top", "bottom"]: orientation = "horizontal" else: diff --git a/lib/mpl_toolkits/axes_grid1/colorbar.py b/lib/mpl_toolkits/axes_grid1/colorbar.py index 064e25c84559..4f4991a8fe55 100644 --- a/lib/mpl_toolkits/axes_grid1/colorbar.py +++ b/lib/mpl_toolkits/axes_grid1/colorbar.py @@ -820,7 +820,7 @@ def colorbar(mappable, cax=None, ax=None, **kw): ax = plt.gca() if cax is None: cax, kw = make_axes(ax, **kw) - cax.hold(True) + cax._hold = True cb = Colorbar(cax, mappable, **kw) def on_changed(m): diff --git a/matplotlibrc.template b/matplotlibrc.template index 790a2b9f80ce..7c7115625010 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -292,7 +292,6 @@ backend : $TEMPLATE_BACKEND # default face and edge color, default tick sizes, # default fontsizes for ticklabels, and so on. See # http://matplotlib.org/api/axes_api.html#module-matplotlib.axes -#axes.hold : True # whether to clear the axes by default on #axes.facecolor : white # axes background color #axes.edgecolor : black # axes edge color #axes.linewidth : 0.8 # edge linewidth