How Can I Hide The Shafts Of Matplotlib.quiver()
I would like to hide the shaft of the arrows plotted by matplotlib.pyplot.quiver(). There seems to be no parameter to completely remove the shafts, as the arrow head sizes are prop
Solution 1:
One approach is to set the arrowhead size headaxislength
and headlength
such that the head completely covers the shaft. The lengths here are proportional to 'xy', the vector lengths, so we have to scale 1. / width
(the inverse proportionality) by the vector length, np.sqrt(u**2 + v**2)
import matplotlib.pyplotas plt
import numpy as np
u = v = 2
length = np.sqrt(u**2 + v**2)
width=0.005
hal = hl = 1. / width * length
plt.quiver(0, 0, u, v, angles='xy', scale_units='xy', scale=1,
headwidth=hl,
headaxislength=hal,
headlength=hl,
width=width)
plt.axis([-2, u+1, -2, v+1])
Post a Comment for "How Can I Hide The Shafts Of Matplotlib.quiver()"