I want to create a legend for arrows of diferent widths that is independent from elements in the plot, so I am using a proxy artist with matplotlib.patch.FancyArrow
I took inspiration from this answer on using HandlerPatch but I can't change the arrow widths. Instead of having a thin and a thick arrow as specified in the arrows handle, I get two arrows with default thickness.
Edit: Width can be specified in the Handler function but then it will be the same for both arrows. I want to specify different marker's properties.
import matplotlib.pyplot as plt
from matplotlib.legend_handler import HandlerPatch
import matplotlib.patches as mpatches
def make_legend_arrow(legend, orig_handle,
xdescent, ydescent,
width, height, fontsize):
p = mpatches.FancyArrow(0,
0.50*height,
15,
0,
head_width=width,
head_length=10,
)
return p
f = plt.figure()
arrows = [mpatches.FancyArrow(0, 0, 0, 0, fc='blue',
width=10),
mpatches.FancyArrow(0, 0, 0, 0, fc='red',
width=2)]
plt.legend(handles=arrows,
labels=['thick','thin'],
handler_map={mpatches.FancyArrow : HandlerPatch(patch_func=make_legend_arrow),
})