Skip to content

Commit c6b065c

Browse files
author
Tino Michael
committed
added commet
1 parent 8a38582 commit c6b065c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

matplotlib2tikz/legend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def draw_legend(data, obj):
202202
# Set color of lines in legend
203203
for handle in obj.legendHandles:
204204
try:
205+
# when using matplotlib colours like "darkred" or "darkorange",
206+
# `handle.get_color` will create nested RGBA codes
207+
# e.g. `[[ 0.54509804, 0., 0., 1.]]` which casuse mpl to throw an error.
208+
# catch this error, `numpy.squeeze` the colour code and try again
205209
try:
206210
data, legend_color, _ = mycol.mpl_color2xcolor(
207211
data, handle.get_color())

0 commit comments

Comments
 (0)