scale_size_binned ¶
scale_size_binned(
range: Sequence[Number] | 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: Number | None = None,
guide: Guide | None = None,
trans: Transform | None = None,
format: str | None = None,
) -> FeatureSpec
Map size to binned sizes (ggplot2).
Each value takes the size at the middle of its bin, so sizes step from bin to
bin. The legend is guide_bins(): one key per bin, labelled on its edges.
Parameters:
-
range(list of float, default:None) –[smallest, largest]size, as inscale_size(default about 1.4..9.5). -
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 outer edges of the legend.
-
oob((squish, censor), default:"squish") –What data outside
limitsmaps to: the end bins ("squish") orna_value("censor"). -
na_value(float, default:None) –Size of missing data.
-
guide(str or FeatureSpec, default:None) –"bins"(default),"legend"(one key per bin labelled with its ends, e.g. "20 - 40"),"none", or aguide_bins()/guide_legend()spec. -
trans(str, default:None) –Transformation of the data, as in
scale_size; 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 = {"country": ["Iceland", "Norway", "Spain", "Japan", "India"],
... "people": [0.38, 5.5, 48, 124, 1430], "area": [103, 385, 506, 378, 3287]}
>>> plot = ggplot(data, aes("area", "people", size="area")) + geom_point()
>>> plot = plot + scale_size_binned(n_breaks=3)