scale_fill_binned ¶
scale_fill_binned(
low: Color | None = None,
high: Color | None = None,
name: str | None = None,
breaks: Breaks | None = None,
labels: Labels | None = None,
limits: Limits | None = None,
n_breaks: int | None = None,
nice_breaks: bool = True,
right: bool = True,
show_limits: bool = False,
oob: Oob = "squish",
na_value: Color | Number | None = None,
guide: Guide | None = None,
trans: Transform | None = None,
format: str | None = None,
) -> FeatureSpec
Map fill to binned colors: scale_fill_steps (ggplot2).
ggplot2's default binned color scale, the same as scale_fill_steps.
Parameters:
-
low(str, default:"#132B43", "#56B1F7") –Colors of the lowest and highest bin.
-
high(str, default:"#132B43", "#56B1F7") –Colors of the lowest and highest bin.
-
name(str, default:None) –Legend title.
-
breaks(list, default:None) –Bin edges inside the data range (data units). Default: about
n_breaksgenerated ones. -
labels(list of str or dict, default:None) –One label per break (a dict maps breaks to labels).
-
limits(list, default:None) –[low, high]range of the bins. Without limits orbreaks, the ends move out so the end bins are as wide as the others (ggplot2). -
n_breaks(int, default:None) –How many breaks to aim for (default 5).
-
nice_breaks(bool, default:True) –Round break values; False spaces
n_breaksbreaks evenly over the range. -
right(bool, default:True) –Bins are closed on the right: a value on a break joins the bin below it.
-
show_limits(bool, default:False) –Also label the two ends of the colorbar.
-
oob((squish, censor), default:"squish") –What data outside
limitsmaps to: the end bins ("squish") orna_value("censor"). -
na_value(str, default:None) –Color of missing data.
-
guide(str or FeatureSpec, default:None) –"colorbar"(default, drawn as steps),"legend","none", or aguide_colorbar()/guide_legend()spec. -
trans(str, default:None) –Transformation of the data, as in
scale_color_gradient; breaks are generated in transformed units. -
format(str, default:None) –Label format, e.g.
".1f"or",".labelstake precedence.
Returns:
-
FeatureSpec–The scale.
Raises:
-
SpecError–If
oobis not"squish"or"censor".
Examples:
>>> from ggrust import *
>>> data = {"x": [1, 2, 3] * 3, "y": [1] * 3 + [2] * 3 + [3] * 3,
... "change": [-3, -1, 0, -2, 0, 2, 0, 1, 4]}
>>> plot = ggplot(data, aes("x", "y", fill="change")) + geom_tile()
>>> plot = plot + scale_fill_binned()
Widen the limits and choose the end colors:
>>> base = ggplot(data, aes("x", "y", fill="change")) + geom_tile()
>>> plot = base + scale_fill_binned(low="white", high="darkgreen", limits=[-6, 6])
Widen the limits and choose the end colors