Skip to content

Commit 013dfc1

Browse files
committed
Fix stem(use_line_collection)
1 parent 9faf231 commit 013dfc1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/matplotlib/axes/_axes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2779,8 +2779,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
27792779

27802780
# New behaviour in 3.1 is to use a LineCollection for the stemlines
27812781
if use_line_collection:
2782-
stemlines = []
27832782
stemlines = [((xi, bottom), (xi, yi)) for xi, yi in zip(x, y)]
2783+
if linestyle is None:
2784+
linestyle = rcParams['lines.linestyle']
27842785
stemlines = mcoll.LineCollection(stemlines, linestyles=linestyle,
27852786
colors=linecolor,
27862787
label='_nolegend_')

lib/matplotlib/tests/test_axes.py

+13
Original file line numberDiff line numberDiff line change
@@ -3070,6 +3070,19 @@ def test_stem(use_line_collection):
30703070
ax.legend()
30713071

30723072

3073+
@check_figures_equal(extensions=['png'])
3074+
def test_stem_params(fig_test, fig_ref):
3075+
x = np.linspace(0, 3.14, 37)
3076+
y = np.sin(x)
3077+
3078+
ax = fig_test.subplots()
3079+
ax.stem(x, y, linefmt='grey', use_line_collection=True)
3080+
3081+
ax = fig_ref.subplots()
3082+
with pytest.warns(UserWarning):
3083+
ax.stem(x, y, linefmt='grey')
3084+
3085+
30733086
def test_stem_args():
30743087
fig = plt.figure()
30753088
ax = fig.add_subplot(1, 1, 1)

0 commit comments

Comments
 (0)