8000 Deprecate stem(..., use_line_collection=False) · matplotlib/matplotlib@1f6021a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f6021a

Browse files
committed
Deprecate stem(..., use_line_collection=False)
as suggested in a75c716 > We could consider deprecating use_line_collection later (as it's > basically an artefact of the transition), though there's no real hurry > for it. The old non-linecollection way handles the presence of markers differently. In the interest of simplification, we should deprecate it. I expect that it's barely used because users would have to explicitly opt-in to the old behavior.
1 parent c9bc943 commit 1f6021a

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``stem(..., use_line_collection=False)``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated with no replacement. This was compatibility fallback to a
4+
former more inefficient representation of the stem lines.

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,6 +2804,7 @@ def broken_barh(self, xranges, yrange, **kwargs):
28042804
return col
28052805

28062806
@_preprocess_data()
2807+
@_api.delete_parameter("3.6", "use_line_collection")
28072808
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28082809
label=None, use_line_collection=True, orientation='vertical'):
28092810
"""
@@ -2870,11 +2871,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28702871
The label to use for the stems in legends.
28712872
28722873
use_line_collection : bool, default: True
2874+
*Deprecated since 3.6*
2875+
28732876
If ``True``, store and plot the stem lines as a
28742877
`~.collections.LineCollection` instead of individual lines, which
28752878
significantly increases performance. If ``False``, defaults to the
2876-
old behavior of using a list of `.Line2D` objects. This parameter
2877-
may be deprecated in the future.
2879+
old behavior of using a list of `.Line2D` objects.
28782880
28792881
data : indexable object, optional
28802882
DATA_PARAMETER_PLACEHOLDER

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2837,8 +2837,9 @@ def stackplot(
28372837
@_copy_docstring_and_deprecators(Axes.stem)
28382838
def stem(
28392839
*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2840-
label=None, use_line_collection=True, orientation='vertical',
2841-
data=None):
2840+
label=None,
2841+
use_line_collection=_api.deprecation._deprecated_parameter,
2842+
orientation='vertical', data=None):
28422843
return gca().stem(
28432844
*args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt,
28442845
bottom=bottom, label=label,

lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,9 +3826,14 @@ def test_stem(use_line_collection):
38263826
fig, ax = plt.subplots()
38273827
# Label is a single space to force a legend to be drawn, but to avoid any
38283828
# text being drawn
3829-
ax.stem(x, np.cos(x),
3830-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3831-
use_line_collection=use_line_collection)
3829+
if use_line_collection:
3830+
ax.stem(x, np.cos(x),
3831+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
3832+
else:
3833+
with pytest.warns(match='deprecated'):
3834+
ax.stem(x, np.cos(x),
3835+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3836+
use_line_collection=False)
38323837
ax.legend()
38333838

38343839

@@ -3868,9 +3873,16 @@ def test_stem_orientation(use_line_collection):
38683873
x = np.linspace(0.1, 2*np.pi, 50)
38693874

38703875
fig, ax = plt.subplots()
3871-
ax.stem(x, np.cos(x),
3872-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3873-
use_line_collection=use_line_collection, orientation='horizontal')
3876+
if use_line_collection:
3877+
ax.stem(x, np.cos(x),
3878+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3879+
orientation='horizontal')
3880+
else:
3881+
with pytest.warns(match='deprecated'):
3882+
ax.stem(x, np.cos(x),
3883+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3884+
use_line_collection=False,
3885+
orientation='horizontal')
38743886

38753887

38763888
@image_comparison(['hist_stacked_stepfilled_alpha'])

0 commit comments

Comments
 (0)
0