The following code yields the figure below. The shape of the arrowhead is dependent on the angle of the arrow. How can I make all of the arrow heads the same symmetric shape? I am asking specifically for Python 3 but general solutions are welcome.
import matplotlib.pyplot as plt
plt.arrow(0, 0, .5, .5, head_width = .1)
plt.arrow(0, 0, .2, .5, head_width = .1)
plt.arrow(0, 0, 0, .5, head_width = .1)
plt.axis((-1, 1, -1 ,1))
plt.show()
It's not possible with plt.arrow
.
I guess the reason plt.arrow
still exists is purely for backwards compatibility. Arrows are better produced by matplotlib.patches.FancyArrowPatch
. The easiest way to get such FancyArrowPatch
in your plot is via plt.annotate
.
import matplotlib.pyplot as plt
prop = dict(arrowstyle="-|>,head_width=0.4,head_length=0.8",
shrinkA=0,shrinkB=0)
plt.annotate("", xy=(.5,.5), xytext=(0,0), arrowprops=prop)
plt.annotate("", xy=(.2,.5), xytext=(0,0), arrowprops=prop)
plt.annotate("", xy=(.0,.5), xytext=(0,0), arrowprops=prop)
plt.axis((-1, 1, -1 ,1))
plt.show()
Arrows are currently a bit underdocumented, but there is still a plan to write up some complete tutorial or guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With