File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -202,8 +202,16 @@ def draw_legend(data, obj):
202
202
# Set color of lines in legend
203
203
for handle in obj .legendHandles :
204
204
try :
205
- data , legend_color , _ = mycol .mpl_color2xcolor (data ,
206
- handle .get_color ())
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
209
+ try :
210
+ data , legend_color , _ = mycol .mpl_color2xcolor (
211
+ data , handle .get_color ())
212
+ except ValueError :
213
+ data , legend_color , _ = mycol .mpl_color2xcolor (
214
+ data , numpy .squeeze (handle .get_color ()))
207
215
data ['legend colors' ].append ('\\ addlegendimage{no markers, %s}\n '
208
216
% legend_color )
209
217
except AttributeError :
You can’t perform that action at this time.
0 commit comments