Python Forum
Quiver fonction - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Quiver fonction (/thread-16924.html)



Quiver fonction - Blaue_Blume04 - Mar-20-2019

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.


RE: Quiver fonction - Larz60+ - Mar-20-2019

Please show your code, or read: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.quiver.html


RE: Quiver fonction - scidam - Mar-21-2019

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()