Skip to content

geom_ydotplot

geom_ydotplot(
    mapping: FeatureSpec | None = None,
    *,
    data: PlotData | 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,
    binwidth: Number | None = None,
    bins: int | None = None,
    method: Literal["dotdensity", "histodot"] | None = None,
    stackdir: Literal[
        "left", "right", "center", "centerwhole"
    ]
    | None = None,
    stackratio: Number | None = None,
    dotsize: Number | None = None,
    stackgroups: bool | None = None,
    center: Number | None = None,
    boundary: Number | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Draw a dot plot along y, one column of stacks at each x.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes().

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

    Layer data; inherits the plot data when None.

  • 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 ) –

    Accepted for compatibility; dot plots have no tooltips yet.

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

    The axis the layer runs along.

  • binwidth (float, default: None ) –

    Width of a bin, and of a dot; overrides bins.

  • bins (int, default: 30 ) –

    Number of bins.

  • method ((dotdensity, histodot), default: "dotdensity" ) –

    dotdensity places stacks where the data is, histodot uses equal bins.

  • stackdir ((left, right, center, centerwhole), default: "left" ) –

    Which way dots stack.

  • stackratio (float, default: 1 ) –

    Distance between dots, as a share of a dot.

  • dotsize (float, default: 1 ) –

    Diameter of a dot, as a share of binwidth.

  • stackgroups (bool, default: False ) –

    Stack dots across groups rather than dodging them.

  • center (float, default: None ) –

    Center of a bin (with method="histodot").

  • boundary (float, default: None ) –

    Boundary between two bins (with method="histodot").

  • 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: color, fill, alpha, stroke.

Returns:

  • LayerSpec –

    The layer.

Raises:

  • SpecError –

    If method or stackdir is not accepted (when the plot is built).

Examples:

>>> from ggrust import *
>>> data = {"group": ["a", "a", "b"], "height": [1.2, 1.3, 1.7]}
>>> plot = ggplot(data, aes("group", "height")) + geom_ydotplot(binwidth=0.2)

Dots stacked from the middle of each group, like a violin of dots:

>>> from ggrust.data import iris
>>> plot = ggplot(iris, aes("species", "sepal_length", fill="species")) + geom_ydotplot(
...     binwidth=0.1, stackdir="center"
... )

Dots stacked from the middle of each group, like a violin of dots