Skip to content

Commit 6091d11

Browse files
committed
Merge pull request matplotlib#3729 from alimuldal/fix_eventplot_colors_arg
BUG : handling of color=None by eventplot(), fixes matplotlib#3728
2 parents c9898ea + e754807 commit 6091d11

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/matplotlib/axes/_axes.py

+2-2
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

Loading

lib/matplotlib/tests/test_axes.py

+17
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,23 @@ def test_eventplot():
22012201
np.testing.assert_equal(num_collections, num_datasets)
22022202

22032203

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

0 commit comments

Comments
 (0)