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

Skip to content

Commit 78e2134

Browse files
afvincenttacaswell
authored andcommitted
Naive fix for issue 8193
1 parent f5f3d79 commit 78e2134

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,15 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
11811181
lineoffsets = [None]
11821182
if len(colors) == 0:
11831183
colors = [None]
1184+
try:
1185+
# Early conversion of the colors into RGBA values to take care
1186+
# of cases like colors='0.5' or colors='C1'. (Issue #8193)
1187+
colors = mcolors.to_rgba_array(colors)
1188+
except ValueError:
1189+
# Will fail if any element of *colors* is None. But as long
1190+
# as len(colors) == 1 or len(positions), the rest of the
1191+
# code should process *colors* properly.
1192+
pass
11841193

11851194
if len(lineoffsets) == 1 and len(positions) != 1:
11861195
lineoffsets = np.tile(lineoffsets, len(positions))

0 commit comments

Comments
 (0)