I am plotting a small arrow within a matplotlib plot, using arrow = axes.arrow(3.3,arrow_height,-0.2,0, color="k", shape="full", width=0.3, length_includes_head=True, head_width=1, head_length=0.1)
. I then add "arrow" to my custom list of handles handles_ordered.append(arrow)
which then contains the related FancyArrow object print(handles_ordered)
gives: [<BarContainer object of 1 artists>, <BarContainer object of 1 artists>, <BarContainer object of 1 artists>, <BarContainer object of 1 artists>, <BarContainer object of 1 artists>, <matplotlib.lines.Line2D object at 0x7f2bacefdb38>, <matplotlib.patches.FancyArrow object at 0x7f2bacefd908>]
.
However in the legend instead of an arrow there is a black patch. Does anyone know whats wrong?
Asked
Active
Viewed 41 times
0

Vroni
- 347
- 1
- 5
- 16
-
1Does [Matplotlib legend for an arrow](https://stackoverflow.com/questions/22348229/matplotlib-legend-for-an-arrow) help? – JohanC Jan 19 '21 at 18:36
-
Well, you either need all that stuff with `HandlerPatch` (second part of first answer), or you could use a Latex arrow (the second answer, but with `\leftarrow`). – JohanC Jan 19 '21 at 20:52
-
Yes, you are right.Trying it exactly like in your shared link helped. Now I managed to draw the arrow inside an otherwise empty legend. I will need to figure out how to add it to the other entries in that legend! But Thanks a lot for pointing it out! – Vroni Jan 19 '21 at 20:53
-
Sorry I seem to have deleted my previous (incorrect) answer while you were answering. Did I also delete something that you wrote? – Vroni Jan 19 '21 at 20:55
-
1[Creating custom legends](https://matplotlib.org/3.3.3/gallery/text_labels_and_annotations/custom_legends.html) will probably be helpful. – JohanC Jan 19 '21 at 20:59