scale_fill_distiller ¶
scale_fill_distiller(
type: Literal["seq", "div", "qual"] | None = None,
palette: str | int | None = None,
direction: int = -1,
name: str | None = None,
breaks: Breaks | None = None,
labels: Labels | None = None,
limits: Limits | None = None,
na_value: Color | None = None,
guide: Guide | None = None,
trans: Transform | None = None,
format: str | None = None,
*,
oob: Oob | None = None,
rescaler: Rescaler | None = None,
) -> FeatureSpec
Map continuous fill with a ColorBrewer palette as a smooth gradient.
Parameters:
-
type((seq, div, qual), default:"seq") –Palette family; needed with a palette index.
-
palette(str or int, default:None) –Palette name or 0-based index within
type. Default:Blues. -
direction((-1, 1), default:-1) –-1 (as ggplot2) puts the palette's last color at the low end.
-
name(str, default:None) –Legend title.
-
breaks(list, default:None) –Values that get a colorbar tick.
-
labels(list of str or dict, default:None) –One label per break.
-
limits(list, default:None) –[low, high]data range. -
oob((censor, squish), default:"censor") –What data outside
limitsmaps to. -
rescaler(callable, default:None) –rescaler(x, to, from_): maps the datax(a polarsSeriesof the finite values, in transformed units) fromfrom_(the scale's range) toto((0.0, 1.0)) before the palette is applied; results outsidetogetna_value. Default: linear. Not in lets-plot (ggplot2rescaler). -
na_value(str, default:None) –Color of missing data and data outside
limits. -
guide(str or FeatureSpec, default:None) –"colorbar","legend","none", or a guide spec. -
trans(str, default:None) –Transformation of the data.
-
format(str, default:None) –Label format.
Returns:
-
FeatureSpec–The scale.
Examples:
>>> from ggrust import *
>>> data = {"x": [1, 2, 1, 2], "y": [1, 1, 2, 2], "rain": [3, 8, 12, 20]}
>>> plot = ggplot(data, aes("x", "y", fill="rain")) + geom_tile()
>>> plot = plot + scale_fill_distiller(palette="YlGnBu", direction=1)
Dark to light (the default direction), over wider limits:
>>> base = ggplot(data, aes("x", "y", fill="rain")) + geom_tile()
>>> plot = base + scale_fill_distiller(palette="Greens", limits=[0, 30])
Dark to light (the default direction), over wider limits