问题
I'm trying to plot a simple quiver plot (e.g. as in the matplotlib gallery: http://matplotlib.org/examples/pylab_examples/quiver_demo.html), although I don't want the autoscaling feature enabled.
I only want to show the field direction, not the magnitude.
Is there a way to set the arrow size as constant please? I tried playing with the scale and scale units but this just seems to change all arrows by some common factor.
Thanks
回答1:
Changing scale won't work for this. You need to normalize the vectors, e.g.
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
# Normalize the arrows:
U = U / np.sqrt(U**2 + V**2);
V = V / np.sqrt(U**2 + V**2);
plt.figure()
plt.title('Normalized arrows')
Q = plt.quiver(X, Y, U, V, units='width')
qk = plt.quiverkey(Q, 0.9, 0.9, 2, r'$2 \frac{m}{s}$', labelpos='E',
coordinates='figure')
来源:https://stackoverflow.com/questions/44780933/matplotlib-quiver-plotting-with-constant-arrow-size