Skip to content

scale_grey

scale_grey(
    aesthetic: str | Sequence[str],
    *,
    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

Greys from lightness start to end, for color aesthetics.

Works for categories and continuous data (a grey gradient).

Parameters:

  • aesthetic (str or list of str) –

    The color aesthetic(s), e.g. "fill" or ["color", "fill"].

  • 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 or dict, default: None ) –

    Values that get a legend key or a colorbar tick (a dict maps labels to breaks).

  • 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 for discrete data; longer labels are cut.

  • limits (list, default: None ) –

    The categories (and their order), or a [low, high] data range.

  • oob ((censor, squish), default: "censor" ) –

    What continuous data outside limits maps to. Not in lets-plot.

  • 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 (str, default: None ) –

    Transformation of continuous data, e.g. "log10".

  • format (str, default: None ) –

    Label format, e.g. ".1f". labels take precedence.

Returns:

  • FeatureSpec –

    The scale, or a FeatureSpecArray of one scale per aesthetic for a list.

Raises:

  • UnsupportedValueError –

    If aesthetic is not a string or a list of strings.

  • SpecError –

    If aesthetic is an empty list.

  • ValueError –

    If start or end is outside 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", fill="pet"))
>>> plot = plot + geom_point(shape=21, size=6, alpha=0.5)
>>> plot = plot + scale_grey(["color", "fill"], start=0.1, end=0.7)