Matplotlib.patches.FancyArrow has a sparse tail

When I execute this code:

plt.figure(figsize=(3,3))
plt.xlim(-3, 3); plt.ylim(-3,3); 
plt.arrow(0,0, 2, 2, head_length=1.4, head_width=1.8, width=1.4,
   alpha=0.2, length_includes_head=True, fc='r')

      

I am getting the following output:

enter image description here

However, I don't want the tail to be compressed. On my other computer, I don't have this problem. Does anyone know how to solve it?

My matplotlib version is 2.0.0.

+3


source to share


1 answer


It seems to be some kind of bug in arrow

. You expect there to be an argument tail_width

that sets the width of the arrow (or its tail). However, this does not exist.

As a workaround, you can use FancyArrowPatch

which you need to manually add to the axes. FancyArrowPatch

has an argument arrowstyle

to which you can specify a string of arguments. Inside this line is "tail_width"

recognized correctly.



import matplotlib.pyplot as plt
import matplotlib.patches as patches

plt.figure(figsize=(3,3))
plt.xlim(-3, 3); plt.ylim(-3,3);

style="Simple,head_length=28,head_width=36,tail_width=20"
plt.gca().add_patch(
        patches.FancyArrowPatch((0,0), (2,2),arrowstyle=style,alpha=0.2,fc='r' ))

plt.show()

      

enter image description here

+3


source







All Articles