Skip to content

geom_contour_filled

geom_contour_filled(
    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,
    bins: int | None = None,
    binwidth: float | None = None,
    breaks: Sequence[float] | None = None,
    color_by: str | None = None,
    fill_by: str | None = None,
    na_rm: bool | None = None,
    **other_args: Any,
) -> LayerSpec

Fill the bands between the contour lines of z by band (ggplot2 geom_contour_filled).

The rows give z at grid nodes, in any order; a missing node leaves a hole. Each band between two consecutive breaks is one ordered category, ..level.. = "(low, high]", so the legend lists the bands and any discrete fill scale applies (scale_fill_viridis() for ggplot2's look). geom_contourf is lets_plot's variant with a continuous ..level.. and a colorbar.

Parameters:

  • mapping (FeatureSpec, default: None ) –

    Aesthetic mapping from aes(): x, y, z (required), fill, color, alpha, size, linetype.

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

    Layer data; inherits the plot data when None.

  • stat (str, default: None ) –

    Statistical transformation, by name; "contour_filled" when None.

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

    Position adjustment: a name such as "identity" 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 ) –

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

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

    Rows to draw: a sampling_*() spec, an int n (sampling_random(n)) or "none". Default: 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).

  • bins (int, default: None ) –

    Number of bands; the z range is widened to round steps first (ggplot2). Default: about 10 bands at R's pretty() breaks.

  • binwidth (float, default: None ) –

    Height of each band, on multiples of it; used when bins is not given.

  • breaks (list of float, default: None ) –

    Explicit band edges (z values, at least two); win over bins and binwidth. Nothing is drawn below the first or above the last.

  • 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 ("fill" or "color").

  • 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 fill="steelblue" or alpha=0.5.

Returns:

  • LayerSpec –

    The layer.

Examples:

>>> from ggrust import *
>>> import numpy as np
>>> x, y = np.meshgrid(np.linspace(-2, 2, 40), np.linspace(-2, 2, 40))
>>> data = {"x": x.ravel(), "y": y.ravel(), "z": np.exp(-(x**2 + y**2)).ravel()}
>>> plot = ggplot(data, aes("x", "y", z="z")) + geom_contour_filled()