Skip to content

Update Facetgrid api to match seaborn #10176

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

Open
Luluser opened this issue Mar 25, 2025 · 0 comments
Open

Update Facetgrid api to match seaborn #10176

Luluser opened this issue Mar 25, 2025 · 0 comments

Comments

@Luluser
Copy link

Luluser commented Mar 25, 2025

Something I assumed would work:

g = ds.plot(hue="level", col="time")
# Second plot uses the existing FacetGrid's axes
ds2.plot(ax=g.axes.flat, hue="level", col="time")

Gives ValueError: Can't use axes when making faceted plots.

How I currectly do it:

Xarray's plotting with facets doesn't work the same way as seaborn's FacetGrid. You currently need to use a manual approach, such as :

g = ds.plot(hue="level", col="time")
for i in range(ds2.time.size):
    ax = g.axs.flat[i]
    ax.set_prop_cycle(None)
    ds2.isel(time=i).plot(ax=ax, hue="level")

More generally:

I think it would be nice to have the functionalities seaborn's facetgrid has, notably passing a facetgrid to the plotting function directly but also including the utility functions that handle the legend or labels to be able to have nice better plots without changing the datasets themselves.

@dcherian dcherian changed the title giving a facetgrid to a plotting function to get a second plot on the axes Update Facetgrid api to match seaborn Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants