Skip to content

geom_crossbar

geom_crossbar(
    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,
    labels: FeatureSpec | None = None,
    fatten: Number | None = None,
    width_unit: str | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Boxes from ymin to ymax at x with a midline at y, dodged by group.

width (default 0.9) is a share of the x resolution.

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: None ) –

    Statistical transformation, by name.

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

    Position adjustment: a name such as "dodge" or a position_*() spec.

  • show_legend (bool, default: None ) –

    False hides this layer from the legend.

  • inherit_aes (bool, default: None ) –

    False ignores the plot's default mapping for this layer.

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

    A legend key for this layer, as in lets_plot; not supported yet (ggrust warns).

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

    lets_plot sampling; accepted and ignored, as ggrust draws every row.

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

    Tooltip content: layer_tooltips(), a list of column names, or "none" to disable tooltips (HTML output).

  • labels (FeatureSpec, default: None ) –

    Midline labels from layer_labels() (lets_plot); not drawn by ggrust yet.

  • fatten (float, default: None ) –

    The midline width as a multiple of the outline width (default 2.5); 0 hides it.

  • width_unit (str, default: None ) –

    Unit of width; only "res" (the x resolution, default) is supported.

  • color_by (str, default: None ) –

    Aesthetic the color scale applies to ("color" or "fill").

  • fill_by (str, default: None ) –

    Aesthetic the fill scale applies to ("color" or "fill").

  • na_rm (bool, default: None ) –

    True removes rows with missing values silently; otherwise they are removed with a warning.

  • **other_args (Any) –

    Constant aesthetics such as color="red" or size=2, and the geom's options. As in lets_plot; options ggrust does not read yet are reported as not supported.

Returns:

  • LayerSpec –

    The layer.

Examples:

>>> from ggrust import aes, geom_crossbar, ggplot
>>> data = {"x": ["a", "b"], "y": [2.0, 3.0], "low": [1.0, 2.5], "high": [3.0, 4.0]}
>>> plot = ggplot(data, aes(x="x", y="y", ymin="low", ymax="high")) + geom_crossbar()