Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39fa9ac

Browse files
committed
Remove use_line_collection argument to stem
1 parent 7a78249 commit 39fa9ac

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
@@ -2896,14 +2896,10 @@ def stackplot(
28962896
@_copy_docstring_and_deprecators(Axes.stem)
28972897
def stem(
28982898
*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2899-
label=None,
2900-
use_line_collection=_api.deprecation._deprecated_parameter,
2901-
orientation='vertical', data=None):
2899+
label=None, orientation='vertical', data=None):
29022900
return gca().stem(
29032901
*args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt,
2904-
bottom=bottom, label=label,
2905-
use_line_collection=use_line_collection,
2906-
orientation=orientation,
2902+
bottom=bottom, label=label, orientation=orientation,
29072903
**({"data": data} if data is not None else {}))
29082904

29092905

lib/matplotlib/tests/test_axes.py

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

40414041

4042-
@pytest.mark.parametrize("use_line_collection", [True, False],
4043-
ids=['w/ line collection', 'w/o line collection'])
40444042
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
4045-
def test_stem(use_line_collection):
4043+
def test_stem():
40464044
x = np.linspace(0.1, 2 * np.pi, 100)
40474045

40484046
fig, ax = plt.subplots()
40494047
# Label is a single space to force a legend to be drawn, but to avoid any
40504048
# text being drawn
4051-
if use_line_collection:
4052-
ax.stem(x, np.cos(x),
4053-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
4054-
else:
4055-
with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'):
4056-
ax.stem(x, np.cos(x),
4057-
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
4058-
use_line_collection=False)
4049+
ax.stem(x, np.cos(x),
4050+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ')
40594051
ax.legend()
40604052

40614053

@@ -4154,23 +4146,14 @@ def test_stem_dates():
41544146
ax.stem(xs, ys)
41554147

41564148

4157-
@pytest.mark.parametrize("use_line_collection", [True, False],
4158-
ids=['w/ line collection', 'w/o line collection'])
41594149
@image_comparison(['stem_orientation.png'], style='mpl20', remove_text=True)
4160-
def test_stem_orientation(use_line_collection):
4150+
def test_stem_orientation():
41614151
x = np.linspace(0.1, 2*np.pi, 50)
41624152

41634153
fig, ax = plt.subplots()
4164-
if use_line_collection:
4165-
ax.stem(x, np.cos(x),
4166-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4167-
orientation='horizontal')
4168-
else:
4169-
with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'):
4170-
ax.stem(x, np.cos(x),
4171-
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4172-
use_line_collection=False,
4173-
orientation='horizontal')
4154+
ax.stem(x, np.cos(x),
4155+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
4156+
orientation='horizontal')
41744157

41754158

41764159
@image_comparison(['hist_stacked_stepfilled_alpha'])

0 commit comments

Comments
 (0)