Python Forum

Full Version: Quiver fonction
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I currently am trying to display on python a gradient using the fonction “quiver”.
Unfortunately I cannot manage to find a way to have the arrow the size I want: I would like to have all the arrow the same size.
All attempts were unsuccessful hitherto. Cry

Thank you for your time.
Quiver function does scaling arrows length when plotting them. To get arrows of the same (and desirable)
length, you need to prevent this behavior by passing scale=1 as a keyword argument.
Look at the following code snippet I just wrote:
import numpy as np
import matplotlib.pyplot as plt

X, Y = np.meshgrid(np.arange(3), np.arange(3)) # 3x3 matrix of arrow beginnings
arrow_length = 0.3 # all arrows will have the same length
arrow_direction = np.pi / 4 # all arrows will have the same direction
U = arrow_length * np.ones(X.shape) * np.cos(arrow_direction)
V = arrow_length * np.ones(X.shape) * np.sin(arrow_direction)

plt.quiver(X, Y, U, V, scale=1) # all arrows should have the same length = 0.3 and inclined to x-axes on 45 deg. 

plt.show()