Same length of vectors using quiver for wind direction representation

Viewed 30

I have a code like

import matplotlib.pyplot as plt
import numpy as np
U= np.array([-2.99, -3.12, -4.18, -4.45, -3.36, -4.66, -3.93, -2.53, -4.6 ,
       -4.71, -3.64, -2.81, -2.5 , -3.35, -3.24])
V= np.array([-6.33, -6.25, -6.54, -7.48, -6.27, -6.48, -5.69, -5.81, -8.81,
       -8.48, -6.86, -6.95, -5.8 , -5.9 , -4.39])
X=np.arange(0, len(U))
plt.figure()
plt.quiver(X,2,U,V)
plt.ylim([1.5,2.5])
plt.show()

enter image description here The figure generated from the code is attached. Here, I am looking for the arrows with equal lengths keeping the same wind direction. I also need to reduce the thickness of the arrows. Please help me.

1 Answers

You can pass constant values for U and V to make all arrows the same length and specify the angles explicitly. The arrow thickness can be adjusted with the width parameter. See the docs for quiver for further details.

plt.quiver(X, 2, np.full_like(X, 1), np.full_like(X, 1), angles=np.rad2deg(np.arctan2(V, U)), width=.002)

enter image description here

Related