Skip to content

Commit d684890

Browse files
committed
Merge pull request #3729 from alimuldal/fix_eventplot_colors_arg
BUG : handling of color=None by eventplot(), fixes #3728
1 parent c29a117 commit d684890

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
11811181
if len(linewidths) == 1:
11821182
linewidths = np.tile(linewidths, len(positions))
11831183
if len(colors) == 1:
1184-
colors = np.asanyarray(colors)
1185-
colors = np.tile(colors, [len(positions), 1])
1184+
colors = list(colors)
1185+
colors = colors * len(positions)
11861186
if len(linestyles) == 1:
11871187
linestyles = [linestyles] * len(positions)
11881188

lib/matplotlib/tests/test_axes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,23 @@ def test_eventplot():
21972197
np.testing.assert_equal(num_collections, num_datasets)
21982198

21992199

2200+
@image_comparison(baseline_images=['test_eventplot_defaults'], extensions=['png'], remove_text=True)
2201+
def test_eventplot_defaults():
2202+
'''
2203+
test that eventplot produces the correct output given the default params
2204+
(see bug #3728)
2205+
'''
2206+
np.random.seed(0)
2207+
2208+
data1 = np.random.random([32, 20]).tolist()
2209+
data2 = np.random.random([6, 20]).tolist()
2210+
data = data1 + data2
2211+
2212+
fig = plt.figure()
2213+
axobj = fig.add_subplot(111)
2214+
colls = axobj.eventplot(data)
2215+
2216+
22002217
@cleanup
22012218
def test_empty_eventplot():
22022219
fig, ax = plt.subplots(1, 1)

0 commit comments

Comments
 (0)