matplotlibplotgeolocationvisualizationnetcdf4

plotting wind direction from netcdf file using quiver


I am doing data visualization from netcdf file (weather data), i want to plot the wind direction as well but it is not working:

ucomp=getvar(ncfile,'U10',timeidx=i)
            vcomp=getvar(ncfile,'V10',timeidx=i)
            net_speed=np.sqrt(ucomp**2+ vcomp**2)
            plt.quiver(lons, lats, ucomp, vcomp)

Here lons and lats are array of longitude and latitude

The output looks like this: output image

instead of showing small arrow sign,it is showing just small grids or something else

i want exact small arrow signs to denote wind direction


Solution

  • plt.quiver has some optional arguments. The matplotlib documentation provides details about these arguments and how to manipulate the arrow size. If the optional argument scale is left out, the arrows are scaled automatically which is the case in your example and the arrows are most likely scaled down to appear as a dot since your grid is very dense. You might consider to reduce the number of grid points, that might already solve the issue.

    I recommend using another argument, headwidth, which increases only the size of the arrow head compared to scale which affects the whole arrow and often leads to a vector field which is hard to recognize at all.

    plt.quiver((lons, lats, ucomp, vcomp, headwidth=5) # you have to see what value leads to appealing results