scale_color_grey ¶
scale_color_grey(
start: Number | None = None,
end: Number | None = None,
name: str | None = None,
breaks: Breaks | None = None,
labels: Labels | None = None,
lablim: int | None = None,
limits: Limits | None = None,
oob: Oob | None = None,
na_value: Color | None = None,
guide: Guide | None = None,
trans: Transform | None = None,
format: str | None = None,
) -> FeatureSpec
Map color to greys, from lightness start to end.
Works for categories and continuous data (a grey gradient).
Parameters:
-
start(float, default:0.2) –Lightness of the low end, 0 (black) to 1 (white).
-
end(float, default:0.8) –Lightness of the high end, 0 to 1.
-
name(str, default:None) –Legend title.
-
breaks(list, default:None) –Values that get a legend key or a colorbar tick.
-
labels(list of str or dict, default:None) –One label per break (a dict maps breaks to labels).
-
lablim(int, default:None) –Maximum label length in characters; longer labels are cut.
-
limits(list, default:None) –[low, high]data range of a continuous scale, or the levels (and their order) of a discrete one. Data outside the limits getsna_value. -
oob((censor, squish), default:"censor") –What continuous data outside
limitsmaps to:"censor"(the default) drawsna_value,"squish"clamps it to the nearest limit so it takes the end color. Missing data staysna_value. Not in lets-plot (ggplot2oob). -
na_value(str, default:None) –Color drawn for missing data and data outside
limits. -
guide(str or FeatureSpec, default:None) –"legend","colorbar","none", or a guide spec. -
trans((identity, log10, log2, sqrt, reverse), default:"identity") –Transformation of the data.
-
format(str, default:None) –Label format, e.g.
".1f".labelstake precedence.
Returns:
-
FeatureSpec–The scale.
Raises:
-
ValueError–startorendoutside 0..1 (after lets_plot's rescaling of 0..100 values).
Examples:
>>> from ggrust import *
>>> data = {"age": [1, 3, 5, 7, 2, 4, 6, 8, 3, 9],
... "weight": [4, 6, 6, 7, 8, 12, 14, 15, 2, 3],
... "pet": ["cat"] * 4 + ["dog"] * 4 + ["rabbit"] * 2}
>>> plot = ggplot(data, aes("age", "weight", color="pet")) + geom_point(size=5)
>>> plot = plot + scale_color_grey(start=0.1, end=0.7)