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

Skip to content

Commit 2282d4b

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 2282d4b

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
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/tests/test_axes.py

Lines changed: 8 additions & 3 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+
with pytest.warns(match='deprecated'):
3831+
ax.stem(x, np.cos(x),
3832+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3833+
use_line_collection=True)
3834+
else:
3835+
ax.stem(x, np.cos(x),
3836+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
38323837
ax.legend()
38333838

38343839

0 commit comments

Comments
 (0)
0