home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1858791026

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1858791026 I_kwDOAMm_X85uyuZy 8093 additional option for ```dataset.plot.quiver``` : provide control over the arrows density through the native ```xarray``` quiver API 8382834 closed 0     8 2023-08-21T07:39:48Z 2023-08-22T13:12:19Z 2023-08-22T13:12:19Z CONTRIBUTOR      

Is your feature request related to a problem?

When plotting a dataset using .plot.quiver, I usually end up having far too many, too small arrows. Looking both at the documentation of the xarray quiver API ( https://xarray.pydata.org/en/v0.17.0/generated/xarray.Dataset.plot.quiver.html ), and at the documentation of the matplotlib quiver API (that is "reachable" from the xarray quiver API through the **kwargs forwarding: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.quiver.html ), I see ways to modify the arrows aspect and plotting properties, but not their densities. Adding ways to control it would be neat. This could be done at the xarray level (with the advantage that more "context knowledge" is available for being able to do it well), or at the matplotlib level (not sure if this is as well suited).

Describe the solution you'd like

I would like to have some options to control the density of my quiver plot arrows directly from the xarray quiver function api. Something like (but open to better suggestions), skip=(skip_x, skip_y) to say how many of the actual data points to plot, or something like density=density to tell how much arrow density I would like on the figure.

Describe alternatives you've considered

After looking into this in a bit of details, if I did not miss anything, it looks like the only option is to directly quiver plot with matplotlib, slicing / skipping by hand the input data: see for example https://stackoverflow.com/questions/33576572/python-quiver-options and similar options. This defeats the point of being able to call dataset.plot.quiver of course, as this forces doing quite a bit of manual operation and falling back to getting the data into numpy arrays and plotting them directly in matplotlib.

I also tried to check if it was possible to directly downsample the xarray dataset and then plot it, by calling a few reshaping (https://docs.xarray.dev/en/stable/user-guide/reshaping.html) commands first, i.e. something like:

my_df.sel(time=time_to_plot).coarsen(rlat=100, rlon=100).plot.quiver(x="longitude", y="latitude", u="data_u", v="data_v")

but that results in an error:

AttributeError: 'DatasetCoarsen' object has no attribute 'plot'

Additional context

No response

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8093/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.748ms · About: xarray-datasette