Skip to content

coord_transform

coord_transform(
    x: Transform | None = None,
    y: Transform | None = None,
    *,
    xlim: Sequence[Number | None] | None = None,
    ylim: Sequence[Number | None] | None = None,
    expand: bool | None = None,
) -> FeatureSpec

Cartesian coordinates with transformed axes (ggplot2).

Unlike a scale transform (scale_x_log10()), the transform applies after the stats: a histogram is binned in data units, a smooth is fitted in data units, and the breaks stay evenly spaced in data units while the axis is warped. Lines are drawn straight between their warped points (ggplot2 bends them). HTML output does not zoom.

Parameters:

  • x (str, default: None ) –

    Axis transform: "identity" (default), "log10", "log2", "log", "log1p", "exp", "logit", "probit", "reciprocal", "pseudo_log", "symlog", "sqrt" or "reverse".

  • y (str, default: None ) –

    Axis transform: "identity" (default), "log10", "log2", "log", "log1p", "exp", "logit", "probit", "reciprocal", "pseudo_log", "symlog", "sqrt" or "reverse".

  • xlim (list, default: None ) –

    [low, high] in data units, as in coord_cartesian.

  • ylim (list, default: None ) –

    [low, high] in data units, as in coord_cartesian.

  • expand (bool, default: True ) –

    False drops the padding around the data on both axes.

Returns:

  • FeatureSpec –

    The coordinate system.

Raises:

  • SpecError –

    If x or y is not a transform name.

Examples:

>>> from ggrust import *
>>> data = {"area": [1, 3, 10, 40, 120, 900], "people": [2, 5, 9, 30, 70, 500]}
>>> plot = ggplot(data, aes("area", "people")) + geom_point()
>>> plot = plot + coord_transform(x="log10", y="log10")