Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FacetGrid plot overlaying multiple variables from same dataset? #7957

Open
guidocioni opened this issue Jul 3, 2023 · 1 comment
Open

FacetGrid plot overlaying multiple variables from same dataset? #7957

guidocioni opened this issue Jul 3, 2023 · 1 comment
Labels
needs triage Issue that has not been reviewed by xarray team member

Comments

@guidocioni
Copy link

What is your issue?

I'm trying to produce a facet plot which contains maps with different overlaid layers (e.g. a pcolormesh and streamplot).
At the moment I'm creating the plot and then iterating over the axes to add the plots manuallay

p = dss['LH'].plot.pcolormesh(
    x='lon',
    y='lat',
    col="exp",
)

for i, ax in enumerate(p.axes.flat):
    ax.coastlines()
    ax.streamplot(
        dss.isel(exp=i).lon.values,
        dss.isel(exp=i).lat.values,
        dss.isel(exp=i)['u_10m_gr'].values,
        dss.isel(exp=i)['v_10m_gr'].values,
    )

This is far from optimal and doesn't really look clean to me. Also, I'm not entirely sure the order of p.axes.flat correspond to the one of the exp dimension I'm using to facet.

All examples in the doc (https://docs.xarray.dev/en/stable/user-guide/plotting.html) refer to the plot method of DataArray, so it seems that, once created the p object, no other variable from the dataset can be accessed.

However, on the doc it is mentioned

TODO: add an example of using the map method to plot dataset variables (e.g., with plt.quiver).

It is not clear to me whether the xarray.plot.FacetGrid.map method can indeed be used to plot another dataset variable or not. If that's not the case, is there any way to achieve what I'm doing without manually looping through the axes?

@guidocioni guidocioni added the needs triage Issue that has not been reviewed by xarray team member label Jul 3, 2023
@CArdilouze
Copy link

CArdilouze commented Jan 1, 2024

I am bringing up this request since I have been facing the same issue. For what it is worth, I have posted a very similar issue with some kind of workaround, but probably on the wrong github repository. See

xarray-contrib/xarray-tutorial#231 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue that has not been reviewed by xarray team member
Projects
None yet
Development

No branches or pull requests

2 participants