8000 Merge pull request #23302 from timhoffm/deprecate-stem-use-linecollec… · matplotlib/matplotlib@ba0db3c · GitHub
[go: up one dir, main page]

Skip to content

Commit ba0db3c

Browse files
authored
Merge pull request #23302 from timhoffm/deprecate-stem-use-linecollection
Deprecate stem(..., use_line_collection=False)
2 parents 51421cf + 1f6021a commit ba0db3c

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
@@ -3847,9 +3847,14 @@ def test_stem(use_line_collection):
38473847
fig, ax = plt.subplots()
38483848
# Label is a single space to force a legend to be drawn, but to avoid any
38493849
# text being drawn
3850-
ax.stem(x, np.cos(x),
3851-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3852-
use_line_collection=use_line_collection)
3850+
if use_line_collection:
3851+
ax.stem(x, np.cos(x),
3852+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
3853+
else:
3854+
with pytest.warns(match='deprecated'):
3855+
ax.stem(x, np.cos(x),
3856+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3857+
use_line_collection=False)
38533858
ax.legend()
38543859

38553860

@@ -3889,9 +3894,16 @@ def test_stem_orientation(use_line_collection):
38893894
x = np.linspace(0.1, 2*np.pi, 50)
38903895

38913896
fig, ax = plt.subplots()
3892-
ax.stem(x, np.cos(x),
3893-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3894-
use_line_collection=use_line_collection, orientation='horizontal')
3897+
if use_line_collection:
3898+
ax.stem(x, np.cos(x),
3899+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3900+
orientation='horizontal')
3901+
else:
3902+
with pytest.warns(match='deprecated'):
3903+
ax.stem(x, np.cos(x),
3904+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3905+
use_line_collection=False,
3906+
orientation='horizontal')
38953907

38963908

38973909
@image_comparison(['hist_stacked_stepfilled_alpha'])

0 commit comments

Comments
 (0)
0