Skip to content

scale_viridis

scale_viridis(
    aesthetic: str | Sequence[str],
    *,
    alpha: Number | None = None,
    begin: Number | None = None,
    end: Number | None = None,
    direction: int | None = None,
    option: str | 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,
    rescaler: Rescaler | None = None,
    na_value: Color | None = None,
    guide: Guide | None = None,
    trans: Transform | None = None,
    format: str | None = None,
) -> FeatureSpec

Map color aesthetics with a viridis-family color map.

Parameters:

  • aesthetic (str or list of str) –

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

  • alpha (float, default: 1 ) –

    Opacity.

  • begin (float, default: 0, 1 ) –

    Part of the color map to use.

  • end (float, default: 0, 1 ) –

    Part of the color map to use.

  • direction ((1, -1), default: 1 ) –

    -1 reverses the colors.

  • option (str, default: "viridis" ) –

    "magma" ("A"), "inferno" ("B"), "plasma" ("C"), "viridis" ("D"), "cividis" ("E"), "turbo" or "twilight".

  • 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.

  • rescaler (callable, default: None ) –

    rescaler(x, to, from_) maps the data to (0, 1) before the palette. Not in lets-plot (ggplot2 rescaler).

  • 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:

Examples:

>>> from ggrust import *
>>> data = {"x": [1, 2, 3, 4, 5], "y": [3, 1, 4, 1, 5], "change": [-2, -1, 0, 1, 2]}
>>> plot = ggplot(data, aes("x", "y", color="change", fill="change"))
>>> plot = plot + geom_point(shape=21, size=10, alpha=0.4)
>>> plot = plot + scale_viridis(["color", "fill"], option="magma", end=0.9)