matplotlib - python pyplot.quiver: Scaling of two superimposed vector fields -


i want plot 2 vector fields in 1 quiver plot. working: each point, there 2 vectors in different colors. problem is, scaling not same: e.g. vector (1,0) first field (sol) displayed length (1,0) field 2 (res).

how can make quiver plot both fields same scale, (1,0) res has same physical length on plot (1,0) sol?

my code:

import numpy np matplotlib import pyplot plt  #res , sol 2 vector fields dimension (ny, nx ,2)  step=3 #not vectors should plotted. every third 1 (in x , y direction)  x,y = np.meshgrid(np.arange(0,nx,step), np.arange(0,ny,step))             q=plt.quiver(x,y,sol[::step,::step,0], sol[::step,::step,1], color='r')     w=plt.quiver(x,y,res[::step,::step,0], res[::step,::step,1], color='b') plt.quiverkey(q, 0.4, 0.15, 1, r'text1', labelpos='s') plt.quiverkey(w, 0.6, 0.15, 1, r'text2', labelpos='s') plt.show() 

you have 2 solutions:

  1. normalize input data , scale it
  2. tell quiver how scale data

solution 2 (fastest):

q=plt.quiver(x,y,sol[::step,::step,0], sol[::step,::step,1], color='r', scale=1) w=plt.quiver(x,y,res[::step,::step,0], res[::step,::step,1], color='b', scale=1) 

you may adjust scale value, have keep same values in both quivers in order expect. this thread helped in case think it's not overspecification give same scale each quiver.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -