You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
Something I assumed would work:
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 :
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.
The text was updated successfully, but these errors were encountered: