Skip to content

Commit 13d962a

Browse files
committed
Improve stem orientation tests and what's new doc.
1 parent c022b22 commit 13d962a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Added *orientation* parameter for stem plots
22
--------------------------------------------
3-
When creating stem plots, you can now pass in an *orientation* argument to
4-
`.Axes.stem` or `.pyplot.stem`.
53

6-
Currently, only ``'vertical'`` and ``'horizontal'`` orientations are supported,
7-
with ``'vertical'`` being the default.
4+
By default, stem lines are vertical. They can be changed to horizontal using
5+
the *orientation* parameter of `.Axes.stem` or `.pyplot.stem`:
86

9-
Example
10-
```````
11-
stem(x, x, orientation='horizontal')
7+
.. plot::
8+
9+
locs = np.linspace(0.1, 2 * np.pi, 25)
10+
heads = np.cos(locs)
11+
12+
fig, ax = plt.subplots()
13+
ax.stem(locs, heads, orientation='horizontal')

lib/matplotlib/tests/test_axes.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -3245,14 +3245,13 @@ def test_hist_stacked_weighted():
32453245
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
32463246
def test_stem(use_line_collection):
32473247
x = np.linspace(0.1, 2 * np.pi, 100)
3248-
args = (x, np.cos(x))
3249-
# Label is a single space to force a legend to be drawn, but to avoid any
3250-
# text being drawn
3251-
kwargs = dict(linefmt='C2-.', markerfmt='k+', basefmt='C1-.',
3252-
label=' ', use_line_collection=use_line_collection)
32533248

32543249
fig, ax = plt.subplots()
3255-
ax.stem(*args, **kwargs)
3250+
# Label is a single space to force a legend to be drawn, but to avoid any
3251+
# text being drawn
3252+
ax.stem(x, np.cos(x),
3253+
linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ',
3254+
use_line_collection=use_line_collection)
32563255

32573256
ax.legend()
32583257

@@ -3284,12 +3283,11 @@ def test_stem_dates():
32843283
@image_comparison(['stem_orientation.png'], style='mpl20', remove_text=True)
32853284
def test_stem_orientation(use_line_collection):
32863285
x = np.linspace(0.1, 2*np.pi, 50)
3287-
args = (x, np.cos(x))
3288-
kwargs = dict(linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3289-
use_line_collection=use_line_collection)
32903286

32913287
fig, ax = plt.subplots()
3292-
ax.stem(*args, **kwargs, orientation='horizontal')
3288+
ax.stem(x, np.cos(x),
3289+
linefmt='C2-.', markerfmt='kx', basefmt='C1-.',
3290+
use_line_collection=use_line_collection, orientation='horizontal')
32933291

32943292

32953293
@image_comparison(['hist_stacked_stepfilled_alpha'])

0 commit comments

Comments
 (0)