Skip to content

Match R datasets by not making columns categoricals in example data #913

Description

@machow

Plotnine deviates a bit from ggplot2 datasets by explicitly casting columns to categoricals. For example, the mpg dataset has a class column that is a string in ggplot2::mpg, but a categorical in plotnine.data.mpg. This produces a series of behaviors that need to be worked around (similar to the reasoning for readr::read_csv() not doing this; see https://r4ds.hadley.nz/factors.html#summary).

One challenge is that by default when you filter the example data, the levels are all included in plots. This can be worked around, but feels like a bit cumbersome when using plotnine.data to produce examples (and you can always make a column a factor when you want this behavior).

I wonder if it could be useful to match ggplot2 and make these columns remain as strings?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions