Skip to content

facet_grid along a categorical column with unused caregories raises IndexError #930

@ilia-kats

Description

@ilia-kats

Consider this example:

df = pd.DataFrame({"row": [1,1,2,2,3,3,4,4], "col": pd.Categorical([1,7,1,7,1,7,1,7], categories=[1,2,3,4,5,6,7]), "x": 1, "y": 1})
ggplot(df, aes("x", "y")) + geom_point() + facet_grid("row", "col")

This raises

IndexError: single positional indexer is out-of-bounds

This situation can occur when subsetting a dataframe for plotting. The reason is that the matrix multiplication in niteraction does not return unique IDs, so the number of panels is incosistent between what is needed and what is reserved.

I'm on plotnine 0.14.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions