Matplotlib Quiver Scale

I am trying to build some arrows using matploblib with the quiver function. But I want to choose the length of each arrow individually, using an array.

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.quiver http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html

These demos and documentation show that you can change scales proportionally to units (x, y, width, height, xy, inches, ...), is there a way to determine the scale for each arrow?

+7
source share
1 answer

To indicate each position of the arrow, and the vector and length - the super precision of the quiver graph. So, you need to change the data you draw.

If you have a vector field U and V (the same U and V as your examples), you can normalize them:

N = numpy.sqrt(U**2+V**2) # there may be a faster numpy "normalize" function U2, V2 = U/N, V/N 

Then you can apply any array of scaling factor you want:

 U2 *= F V2 *= F 
+9
source

All Articles