Plotting vector field

Hi,

I’m new to gmt and pygmt. I am plotting a vector field on a map with fixed stem and arrow colors.
Is it possible with pygmt to plot a vector field on a map and use a colormap
to color the stem of each vector based on the windspeed ?

Thanks,
Jean-Marc

Hi @jmbelanger,

It depends on how your vector field is stored as. Is it in a vector/table format, or a grid format?

If it’s a vector/table format, the upcoming PyGMT v0.4.0 release will have a velo function that does this. See the gallery example at https://www.pygmt.org/dev/gallery/seismology/velo_arrow_ellipse.html and API documentation at https://www.pygmt.org/dev/api/generated/pygmt.Figure.velo.html.

However, you’ll need to install the development version of PyGMT to use it now, i.e. run this in your command-line:

pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pygmt

On the other hand, if your data is in a grid format, have a look at Plot wind vectors from a XArray DataArray for inspiration (using grdvector instead). If you could provide a sample of your data, and/or a figure showing what you want it to look like, we might be able to assist further :smiley: