SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.41k stars 359 forks source link

Uncertainty ellipses for quiver #1487

Open tobiscode opened 4 years ago

tobiscode commented 4 years ago

Hi all,

I've recently noted that even after significant searching, I did not find a Python plotting tool or package that enables plotting uncertainty/error ellipses when plotting arrows/vectors with quiver. This is especially useful when plotting displacement fields with associated uncertainties (example), or complex numbers with correlated errors, etc.

Currently, the only way to do this for mapping purposes is to rely on GMT's psvelo, which has been and is used extensively, but requires the full GMT installation and usage via the command-line. Their Python implementation, PyGMT is still in its early stages and it is unknown how long the integration into a Python interface will take (plus, it uses its own backend, so most of Matplotlib's other powerful features wouldn't be usable anyway). Similarly, Cartopy does not have a dedicated quiver analog.

I am not aware of any tools that do this for complex numbers. In both cases, I welcome workarounds, fixes or other packages that implement this functionality and that I missed during my search.

I can imagine that if someone understands how transformations work in Matplotlib/Cartopy, it shouldn't be too hard to add the creation of an ellipses when drawing the arrows (but that is sadly not me).

In my view, offering this functionality would provide a huge boost in usability of Matplotlib and Python in general for many scientific fields.

Cross-link to Matplotlib issue no. 16750

greglucas commented 4 years ago

It looks like you got some good suggestions on the linked thread. The only thing I will point out is that Cartopy does have a quiver function. See the example here: https://scitools.org.uk/cartopy/docs/latest/gallery/regridding_arrows.html#sphx-glr-gallery-regridding-arrows-py

tobiscode commented 4 years ago

Ah yes, thanks - I thought it was just a pass-through to the Matplotlib function but there is actually additional logic, my bad.

tobiscode commented 4 years ago

I've made a Stack Overflow post, let's see what it brings.