Skip to content

Commit a5d18ab

Browse files
committed
Remove use_line_collection argument to stem
1 parent 7c7a34a commit a5d18ab

File tree

3 files changed

+18
-63
lines changed

3 files changed

+18
-63
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,9 +2886,8 @@ def broken_barh(self, xranges, yrange, **kwargs):
28862886
return col
28872887

28882888
@_preprocess_data()
2889-
@_api.delete_parameter("3.6", "use_line_collection")
28902889
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2891-
label=None, use_line_collection=True, orientation='vertical'):
2890+
label=None, orientation='vertical'):
28922891
"""
28932892
Create a stem plot.
28942893
@@ -2932,8 +2931,8 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
29322931
cycle.
29332932
29342933
Note: Markers specified through this parameter (e.g. 'x') will be
2935-
silently ignored (unless using ``use_line_collection=False``).
2936-
Instead, markers should be specified using *markerfmt*.
2934+
silently ignored. Instead, markers should be specified using
2935+
*markerfmt*.
29372936
29382937
markerfmt : str, optional
29392938
A string defining the color and/or shape of the markers at the stem
@@ -2953,14 +2952,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
29532952
label : str, default: None
29542953
The label to use for the stems in legends.
29552954
2956-
use_line_collection : bool, default: True
2957-
*Deprecated since 3.6*
2958-
2959-
If ``True``, store and plot the stem lines as a
2960-
`~.collections.LineCollection` instead of individual lines, which
2961-
significantly increases performance. If ``False``, defaults to the
2962-
old behavior of using a list of `.Line2D` objects.
2963-
29642955
data : indexable object, optional
29652956
DATA_PARAMETER_PLACEHOLDER
29662957
@@ -3024,27 +3015,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
30243015
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
30253016

30263017
# New behaviour in 3.1 is to use a LineCollection for the stemlines
3027-
if use_line_collection:
3028-
if linestyle is None:
3029-
linestyle = mpl.rcParams['lines.linestyle']
3030-
xlines = self.vlines if orientation == "vertical" else self.hlines
3031-
stemlines = xlines(
3032-
locs, bottom, heads,
3033-
colors=linecolor, linestyles=linestyle, label="_nolegend_")
3034-
# Old behaviour is to plot each of the lines individually
3035-
else:
3036-
stemlines = []
3037-
for loc, head in zip(locs, heads):
3038-
if orientation == 'horizontal':
3039-
xs = [bottom, head]
3040-
ys = [loc, loc]
3041-
else:
3042-
xs = [loc, loc]
3043-
ys = [bottom, head]
3044-
l, = self.plot(xs, ys,
3045-
color=linecolor, linestyle=linestyle,
3046-
marker=linemarker, label="_nolegend_")
3047-
stemlines.append(l)
3018+
if linestyle is None:
3019+
linestyle = mpl.rcParams['lines.linestyle']
3020+
xlines = self.vlines if orientation == "vertical" else self.hlines
3021+
stemlines = xlines(
3022+
locs, bottom, heads,
3023+
colors=linecolor, linestyles=linestyle, label="_nolegend_")
30483024

30493025
if orientation == 'horizontal':
30503026
marker_x = heads

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,14 +2922,10 @@ def stackplot(
29222922
@_copy_docstring_and_deprecators(Axes.stem)
29232923
def stem(
29242924
*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2925-
label=None,
2926-
use_line_collection=_api.deprecation._deprecated_parameter,
2927-
orientation='vertical', data=None):
2925+
label=None, orientation='vertical', data=None):
29282926
return gca().stem(
29292927
*args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt,
2930-
bottom=bottom, label=label,
2931-
use_line_collection=use_line_collection,
2932-
orientation=orientation,
2928+
bottom=bottom, label=label, orientation=orientation,
29332929
**({"data": data} if data is not None else {}))
29342930

29352931

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,23 +4047,15 @@ def test_hist_stacked_weighted():
40474047
ax.hist((d1, d2), weights=(w1, w2), histtype="stepfilled", stacked=True)
40484048

40494049

4050-
@pytest.mark.parametrize("use_line_collection", [True, False],
4051-
ids=['w/ line collection', 'w/o line collection'])
40524050
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
4053-
def test_stem(use_line_collection):
4051+
def test_stem():
40544052
x = np.linspace(0.1, 2 * np.pi, 100)
40554053

40564054
fig, ax = plt.subplots()
40574055
# Label is a single space to force a legend to be drawn, but to avoid any
40584056
# text being drawn
4059-
if use_line_collection:
4060-
ax.stem(x, np.cos(x),
4061-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
4062-
else:
4063-
with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'):
4064-
ax.stem(x, np.cos(x),
4065-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
4066-
use_line_collection=False)
4057+
ax.stem(x, np.cos(x),
4058+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
40674059
ax.legend()
40684060

40694061

@@ -4162,23 +4154,14 @@ def test_stem_dates():
41624154
ax.stem(xs, ys)
41634155

41644156

4165-
@pytest.mark.parametrize("use_line_collection", [True, False],
4166-
ids=['w/ line collection', 'w/o line collection'])
41674157
@image_comparison(['stem_orientation.png'], style='mpl20', remove_text=True)
4168-
def test_stem_orientation(use_line_collection):
4158+
def test_stem_orientation():
41694159
x = np.linspace(0.1, 2*np.pi, 50)
41704160

41714161
fig, ax = plt.subplots()
4172-
if use_line_collection:
4173-
ax.stem(x, np.cos(x),
4174-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4175-
orientation='horizontal')
4176-
else:
4177-
with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'):
4178-
ax.stem(x, np.cos(x),
4179-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4180-
use_line_collection=False,
4181-
orientation='horizontal')
4162+
ax.stem(x, np.cos(x),
4163+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4164+
orientation='horizontal')
41824165

41834166

41844167
@image_comparison(['hist_stacked_stepfilled_alpha'])

0 commit comments

Comments
 (0)