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

Skip to content

Commit 88c9d9b

Browse files
authored
Merge pull request #10584 from matplotlib/auto-backport-of-pr-10578
Backport PR #10578 on branch v2.2.x
2 parents f6ebf28 + 74177b9 commit 88c9d9b

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,11 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
12701270
minline = (lineoffsets - linelengths).min()
12711271
maxline = (lineoffsets + linelengths).max()
12721272

1273-
if colls[0].is_horizontal():
1274-
corners = (minpos, minline), (maxpos, maxline)
1275-
else:
1273+
if (orientation is not None and
1274+
orientation.lower() == "vertical"):
12761275
corners = (minline, minpos), (maxline, maxpos)
1276+
else: # "horizontal", None or "none" (see EventCollection)
1277+
corners = (minpos, minline), (maxpos, maxline)
12771278
self.update_datalim(corners)
12781279
self.autoscale_view()
12791280

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,17 @@ def test_empty_eventplot():
32373237
plt.draw()
32383238

32393239

3240+
@pytest.mark.parametrize('data, orientation', product(
3241+
([[]], [[], [0, 1]], [[0, 1], []]),
3242+
('_empty', 'vertical', 'horizontal', None, 'none')))
3243+
def test_eventplot_orientation(data, orientation):
3244+
"""Introduced when fixing issue #6412. """
3245+
opts = {} if orientation == "_empty" else {'orientation': orientation}
3246+
fig, ax = plt.subplots(1, 1)
3247+
ax.eventplot(data, **opts)
3248+
plt.draw()
3249+
3250+
32403251
@image_comparison(baseline_images=['marker_styles'], extensions=['png'],
32413252
remove_text=True)
32423253
def test_marker_styles():

0 commit comments

Comments
 (0)