Skip to content

expand_limits

expand_limits(
    *,
    x: LimitValues = None,
    y: LimitValues = None,
    size: LimitValues = None,
    color: LimitValues = None,
    fill: LimitValues = None,
    alpha: LimitValues = None,
    shape: LimitValues = None,
) -> LayerSpec

Widen the scales of the plot so they include the given values.

Each argument is one value or a list of values for that aesthetic, e.g. expand_limits(y=0) to show the y axis from zero. The values are drawn by an invisible geom_blank layer, so they train the scales and nothing else.

Parameters:

  • x (value or list, default: None ) –

    Values the x scale must include.

  • y (value or list, default: None ) –

    Values the y scale must include.

  • size (value or list, default: None ) –

    Values the size scale must include.

  • color (value or list, default: None ) –

    Values the color scale must include.

  • fill (value or list, default: None ) –

    Values the fill scale must include.

  • alpha (value or list, default: None ) –

    Values the alpha scale must include.

  • shape (value or list, default: None ) –

    Values the shape scale must include.

Returns:

  • LayerSpec –

    A geom_blank layer.

Examples:

>>> from ggrust import *
>>> data = {"x": [-3, 0, 1], "y": [2, 3, -1]}
>>> plot = ggplot(data, aes("x", "y")) + geom_point() + expand_limits(x=-10, y=[-5, 5])