scale_fill_rating

scale_fill_rating(distinct=False, **kwargs)

Rating fill scale.

Maps the rating codes “1” to “5” onto pal_rating, which uses the bands_rating_3() thresholds (1-2 bad, 3 ok, 4-5 good). Set distinct=True for a fully distinct five-colour ramp, which reads better on stacked bars where adjacent segments must be separable. scale_color_rating is an alias of scale_colour_rating.

Parameters

Name Type Description Default
distinct bool Use a distinct shade per point instead of pal_rating, where 1 and 2 share red and 4 and 5 share green. Default False. False
**kwargs Passed to plotnine’s scale_fill_manual(). {}

Returns

Name Type Description
plotnine scale A manual fill scale.

See Also

scale_fill_nps

Examples

>>> from plotnine import ggplot, aes, geom_col
>>> df = pd.DataFrame({"feature": ["a", "b"], "pct": [60, 40], "rating": ["4", "2"]})
>>> ggplot(df, aes("feature", "pct", fill="rating")) + geom_col() + scale_fill_rating()