Color-mapping a 3D quiver function using matplotlib

后端 未结 1 1801
盖世英雄少女心
盖世英雄少女心 2021-01-03 06:25

I have created a lovely 3D displacement vector field in python using Matplotlib and I am happy with the results. However, visually it is not very east to see the magnitude o

相关标签:
1条回答
  • 2021-01-03 06:42

    You have to calculate wind speed (or another array which you use as magnitude) then add this array to quiver function:

    import matplotlib as mpl 
    import matplotlib.pyplot as plt
    from numpy import arange,meshgrid,sqrt
    
    u,v = arange(-50,51,10),arange(-50,51,10)
    u,v = meshgrid(u,v)
    M = sqrt(u*u+v*v) # magnitude
    x,y = u,v
    qq=plt.quiver(x,y,u,v,M,cmap=plt.cm.jet)
    plt.colorbar(qq, cmap=plt.cm.jet)
    plt.show()
    

    0 讨论(0)
提交回复
热议问题