Skip to content

geom_lollipop

geom_lollipop(
    mapping: FeatureSpec | None = None,
    *,
    data: PlotData | None = None,
    stat: str | None = None,
    position: Position | None = None,
    show_legend: bool | None = None,
    inherit_aes: bool | None = None,
    manual_key: ManualKey | None = None,
    sampling: Sampling | None = None,
    tooltips: Tooltips | None = None,
    orientation: Literal["x", "y"] | None = None,
    dir: Literal["v", "h", "s"] | None = None,
    fatten: Number | None = None,
    slope: Number | None = None,
    intercept: Number | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Draw a stick from a baseline to a marker at each (x, y).

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes().

  • data (DataFrame or dict, default: None ) –

    Layer data; inherits the plot data when None.

  • stat (str, default: "identity" ) –

    Statistical transformation, by name.

  • position (str or FeatureSpec, default: "identity" ) –

    Position adjustment.

  • show_legend (bool, default: True ) –

    False hides this layer from the legend.

  • inherit_aes (bool, default: True ) –

    False ignores the plot's mapping.

  • manual_key (str or FeatureSpec, default: None ) –

    A manual legend key for this layer.

  • sampling (FeatureSpec or int, default: None ) –

    Result of a sampling_*() call.

  • tooltips (FeatureSpec or str, default: None ) –

    Result of layer_tooltips(), or "none".

  • orientation ((x, y), default: "x" ) –

    The axis the layer runs along; found from the mapping when None.

  • dir ((v, h, s), default: "v" ) –

    Direction of the sticks: vertical, horizontal, or perpendicular to the baseline.

  • fatten (float, default: 2.5 ) –

    Multiplier of the marker size.

  • slope (float, default: 0 ) –

    Slope of the baseline.

  • intercept (float, default: 0 ) –

    Intercept of the baseline.

  • color_by (str, default: None ) –

    Aesthetic the color scale of this layer reads.

  • fill_by (str, default: None ) –

    Aesthetic the fill scale of this layer reads.

  • na_rm (bool, default: False ) –

    True drops missing values without a warning.

  • **other_args (Any) –

    Constant aesthetics: x, y, size, stroke, linewidth, color, fill, alpha, shape, linetype.

Returns:

  • LayerSpec –

    The layer.

Raises:

  • SpecError –

    If dir is not one of the accepted values (when the plot is built).

Examples:

>>> from ggrust import *
>>> data = {"city": ["a", "b", "c"], "rain": [12, 30, 21]}
>>> plot = ggplot(data, aes("city", "rain")) + geom_lollipop(fatten=3)

Sticks from a baseline at the mean, so each one shows a deviation:

>>> plot = (ggplot(data, aes("city", "rain"))
...         + geom_hline(yintercept=21, linetype="dashed")
...         + geom_lollipop(intercept=21, fatten=3, color="#1f77b4"))

Sticks from a baseline at the mean, so each one shows a deviation