Skip to content

Update Facetgrid api to match seaborn #10176

Open
@Luluser

Description

@Luluser

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions