-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate "hold" kwarg and machinery. #7516
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
Changes from all commits
7c9d4a6
f08a0fb
785a516
dce381e
403ab99
219ce30
0cc0f57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe link these two things? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't understand what you are suggesting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A cross-reference to the relevant functions for clearing the Axes/Figure. |
||
plotting commands. | ||
|
||
|
||
`Artist.update` has return value | ||
-------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "correct" way to document deprecation with numpydoc is through the deprecation notes section, but I don't think this matters much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This puts it out front, so I will consider it at least good enough for now. |
||
|
||
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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not commit to a specific version here? Or at least make it one of 2.2, 2.3 or 2.4, which should be far away enough... Same comments below. (mpl 3.0 sounds a bit like python 4 to me) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is the correct version if we wish to follow SemVer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... which we haven't been doing so far? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not fully concluded in #3070. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just say "in a future feature release" (as opposed to "bugfix release") in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this would generate some controversy... I would like to see "hold" go away ASAP, and I don't have strong opinions about version numbering. It seemed like the discussion in #3070 was leaning in the direction of going wild with major version numbers--why not, Firefox is up to 50.0! Seriously, regardless of how the numbering controversy is resolved, we need to find a way to get releases out more frequently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will at least have a 3.0 when we drop python2 support (so 2018). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be following SemVer, and we certainly are with 2.0. Therefore, when we remove hold it will be |
||
""" | ||
|
||
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*. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use
stacklevel=2
, so that the warning references the caller instead ofpyplot.py
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that just now, but it gives puzzling result when using pyplot commands from the command line, or from a function defined on the command line. I think we are better off leaving the default in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, really?
vs.
looks correct to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is with ipython and stacklevel=2:
and with the default:
For this use, the default looks better to me. What would really be needed for someone to debug a hold kwarg buried in a library is a full stack trace, but we are not going to put that in.