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?
Plotnine deviates a bit from ggplot2 datasets by explicitly casting columns to categoricals. For example, the
mpgdataset has aclasscolumn that is a string inggplot2::mpg, but a categorical inplotnine.data.mpg. This produces a series of behaviors that need to be worked around (similar to the reasoning forreadr::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.datato 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?