from plotnine import ggplot, aes, geom_bar
from plotnine.data import mtcars
="factor(cyl)")) + geom_bar() ggplot(mtcars, aes(x
plotnine.mapping._eval_environment.factor
=None, ordered=None) factor(values, categories
Turn x in to a categorical (factor) variable
It is just an alias to pandas.Categorical
Parameters
values : Sequence[Any]
-
The values of the categorical. If categories are given, values not in categories will be replaced with NaN.
categories : Sequence[Any] | None = None
-
The unique categories for this categorical. If not given, the categories are assumed to be the unique values of
values
(sorted, if possible, otherwise in the order in which they appear). ordered : bool | None = None
-
Whether or not this categorical is treated as a ordered categorical. If True, the resulting categorical will be ordered. An ordered categorical respects, when sorted, the order of its
categories
attribute (which in turn is thecategories
argument, if provided).