scale_fill_nps
scale_fill_nps(**kwargs)NPS group fill scale.
Maps the NPS-group coding from nps_group() (“-1” detractor, “0” passive, “1” promoter) onto the pal_nps red, amber and green palette, so the colours carry their usual meaning. Used by plot_nps().
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| **kwargs | Passed to plotnine’s scale_fill_manual(). |
{} |
Returns
| Name | Type | Description |
|---|---|---|
| plotnine scale | A manual fill scale. |
See Also
nps_group, plot_nps
Examples
>>> from plotnine import ggplot, aes, geom_col
>>> df = pd.DataFrame({"score": ["0", "1", "2"], "pct": [20, 30, 50], "group": ["-1", "0", "1"]})
>>> ggplot(df, aes("score", "pct", fill="group")) + geom_col() + scale_fill_nps()