Skip to content

geom_dotplot

geom_dotplot(
    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,
    binwidth: Number | None = None,
    bins: int | None = None,
    method: Literal["dotdensity", "histodot"] | None = None,
    stackdir: Literal["up", "down", "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: each observation a dot, stacked within its bin.

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.

  • 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 ((up, down, center, centerwhole), default: "up" ) –

    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 (with method="histodot").

  • 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 = {"height": [1.2, 1.3, 1.3, 1.7, 2.0, 2.1]}
>>> plot = ggplot(data, aes(x="height")) + geom_dotplot(binwidth=0.2)

Groups stacked on top of each other in equal bins:

>>> from ggrust.data import iris
>>> plot = ggplot(iris, aes("sepal_length", fill="species")) + geom_dotplot(
...     binwidth=0.2, method="histodot", stackgroups=True
... )

Groups stacked on top of each other in equal bins