Skip to content

geom_mark_ellipse

geom_mark_ellipse(
    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,
    expand: Number | None = None,
    radius: Number | None = None,
    n: int | None = None,
    tol: Number | None = None,
    label_margin: Number | Sequence[Number] | None = None,
    label_width: Number | None = None,
    label_minwidth: Number | None = None,
    label_hjust: Number | Sequence[Number] | None = None,
    label_fontsize: Number | Sequence[Number] | None = None,
    label_family: str | Sequence[str] | None = None,
    label_lineheight: Number
    | Sequence[Number]
    | None = None,
    label_fontface: str | Sequence[str] | None = None,
    label_fill: str | None = None,
    label_colour: str | Sequence[str] | None = None,
    label_buffer: Number | None = None,
    con_colour: str | None = None,
    con_size: Number | None = None,
    con_type: Literal | None = None,
    con_linetype: str | int | None = None,
    con_border: Literal | None = None,
    con_cap: Number | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Outline each group of points with its smallest enclosing ellipse.

As geom_mark_ellipse in the R package ggforce: Khachiyan's minimum enclosing ellipse of each group's points (in screen space), grown by expand. Callouts as in geom_mark_hull.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes(). Needs x and y; also reads label, description and filter.

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

    Layer data; inherits the plot data when None.

  • stat (str, default: None ) –

    Statistical transformation, "identity" by default.

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

    Position adjustment.

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

    This layer's key in a manual legend: a label, or layer_key().

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

    Accepted for lets_plot compatibility; marks have no tooltips yet.

  • expand (float, default: 5 ) –

    Millimetres the mark extends beyond the ellipse.

  • radius (float, default: None ) –

    Corner radius in millimetres; expand by default (a smooth outline).

  • n (int, default: 100 ) –

    Points on the ellipse outline.

  • tol (float, default: 0.01 ) –

    Convergence tolerance of Khachiyan's algorithm.

  • label_margin (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_width (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_minwidth (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_hjust (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_fontsize (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_family (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_lineheight (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_fontface (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_fill (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_colour (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • label_buffer (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_colour (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_size (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_type (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_linetype (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_border (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • con_cap (optional, default: None ) –

    Callout options; see geom_mark_hull.

  • na_rm (bool, default: None ) –

    True removes rows with missing values silently.

  • **other_args (Any) –

    Constant aesthetics.

Returns:

  • LayerSpec –

    The layer.

Raises:

  • SpecError –

    If a length is negative, tol is not positive or a connector option is not one of the accepted names.

  • UnsupportedValueError –

    If a length or tol is not a number.

Examples:

>>> from ggrust import *
>>> data = {"x": [1, 2, 3, 2, 6, 7, 8, 7], "y": [1, 2, 1, 0, 5, 6, 5, 4],
...         "group": ["a"] * 4 + ["b"] * 4}
>>> plot = (ggplot(data, aes("x", "y")) + geom_mark_ellipse(aes(fill="group"))
...         + geom_point())