Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,8 +2779,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,

# New behaviour in 3.1 is to use a LineCollection for the stemlines
if use_line_collection:
stemlines = []
stemlines = [((xi, bottom), (xi, yi)) for xi, yi in zip(x, y)]
if linestyle is None:
linestyle = rcParams['lines.linestyle']
stemlines = mcoll.LineCollection(stemlines, linestyles=linestyle,
colors=linecolor,
label='_nolegend_')
Expand Down
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,19 @@ def test_stem(use_line_collection):
ax.legend()


@check_figures_equal(extensions=['png'])
def test_stem_params(fig_test, fig_ref):
x = np.linspace(0, 3.14, 37)
y = np.sin(x)

ax = fig_test.subplots()
ax.stem(x, y, linefmt='grey', use_line_collection=True)

ax = fig_ref.subplots()
with pytest.warns(UserWarning):
ax.stem(x, y, linefmt='grey')


def test_stem_args():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
Expand Down