Skip to content

geom_bracket

geom_bracket(
    mapping: FeatureSpec | None = None,
    *,
    data: PlotData | None = None,
    stat: str | None = None,
    position: Position | None = None,
    show_legend: bool | None = None,
    manual_key: ManualKey | None = None,
    sampling: Sampling | None = None,
    orientation: str | None = None,
    label_format: str | None = None,
    na_text: str | None = None,
    nudge_x: Number | None = None,
    nudge_y: Number | None = None,
    nudge_unit: str | None = None,
    size_unit: str | None = None,
    bracket_shorten: Number | None = None,
    tiplength_unit: str | None = None,
    color_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Labelled brackets from xmin to xmax at height y (significance marks).

Unlike most layers, the plot mapping is not inherited and no legend is shown unless show_legend=True, as in lets_plot.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes(): xmin, xmax, y, label, and color/alpha. Tip lengths (lenstart, lenend) and the bracket line (segment_color, segment_size, segment_alpha) are constants only in ggrust yet, e.g. segment_size=0.5.

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

    Layer data; inherits the plot data when None.

  • orientation (str, default: None ) –

    Only "x" (horizontal brackets) is drawn by ggrust yet.

  • nudge_x (float, default: None ) –

    Shift of the whole bracket in data units.

  • nudge_y (float, default: None ) –

    Shift of the whole bracket in data units.

  • bracket_shorten (float, default: 0 ) –

    Pull both ends toward the middle: 0 keeps the full width, 1 collapses it.

  • tiplength_unit ((size, res, identity, px), default: "size" ) –

    Unit of lenstart/lenend: point size units (2.2 px), the y resolution, data units, or pixels.

  • 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.

  • 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.

  • label_format (str, default: None ) –

    Format pattern of the label text, e.g. ".2f" or "{d} %".

  • na_text (str, default: None ) –

    Text shown for missing values.

  • nudge_unit (str, default: None ) –

    Unit of the nudge: "identity" (data units), "size", "px".

  • size_unit (str, default: None ) –

    Relate size to an axis: "x", "y", "min" or "max".

  • color_by (str, default: None ) –

    Aesthetic the color 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 segment_size=1, and the geom's options. As in lets_plot; options ggrust does not read yet are reported as not supported.

Returns:

  • LayerSpec –

    The layer.