Skip to content

shadow_mark

shadow_mark(
    past: bool = True,
    future: bool = False,
    *,
    exclude_layer: int | Sequence[int] | None = None,
    **aesthetics: str | float,
) -> FeatureSpec

Keep the marks of earlier (or later) states in the background (gganimate shadow_mark).

Each frame also draws the marks of every state already shown (past) and/or still to come (future), as they are on the last frame of their state, behind the frame's own marks. Constant styles such as alpha=0.3 or color="grey" restyle those marks (where the layer has that style). Works with transition_states() (one set of marks per state) and transition_time() (one per time in the data).

Parameters:

  • past (bool, default: True ) –

    Draw the marks of states before the frame.

  • future (bool, default: False ) –

    Draw the marks of states after the frame.

  • exclude_layer (int or sequence of int, default: None ) –

    Layers (counted from 1, as gganimate) that get no marks.

  • **aesthetics (str or float) –

    Constant styles of the marks: alpha, color/colour, fill, size, stroke, shape or linetype. gganimate also takes expressions of the data (alpha = alpha / 2); ggrust takes constants.

Returns:

  • FeatureSpec –

    The shadow (kind "animation"), added to a plot with +. A later shadow replaces an earlier one.

Raises:

  • SpecError –

    If past or future is not a bool, a layer number is not counted from 1, or a style is unknown or not a constant.

Examples:

>>> from ggrust import *
>>> shadow_mark(alpha=0.3, color="grey").props()["shadow"]["aesthetics"]
{'alpha': 0.3, 'color': 'grey'}

Earlier points stay, small and faded:

>>> data = {"time": [1, 2, 3], "x": [1.0, 2.0, 3.0], "y": [1.0, 4.0, 9.0]}
>>> plot = (
...     ggplot(data, aes("x", "y"))
...     + geom_point(size=5)
...     + transition_time("time")
...     + shadow_mark(alpha=0.3, size=2)
... )

Earlier points stay, small and faded