Skip to content
Advertisement

Arrow on a line plot with matplotlib

I’d like to add an arrow to a line plot with matplotlib like in the plot below (drawn with pgfplots).

enter image description here

How can I do (position and direction of the arrow should be parameters ideally)?

Here is some code to experiment.

JavaScript

Thanks.

Advertisement

Answer

In my experience this works best by using annotate. Thereby you avoid the weird warping you get with ax.arrow which is somehow hard to control.

EDIT: I’ve wrapped it into a little function.

JavaScript

It’s not very intuitive but it works. You can then fiddle with the arrowprops dictionary until it looks right.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement