Skip to content

lineplot

lineplot(data, *, x, y, hue=None, hue_order=None, estimator=None, color=None, palette=None)

Plot a line chart with optional aggregation.

Accepts any DataFrame supported by narwhals. Numeric x values must be evenly spaced — Mermaid places all points equidistantly regardless of actual values.

Parameters:

Name Type Description Default
data IntoFrame

Input data. Any narwhals-compatible DataFrame or LazyFrame.

required
x str

Column name for the x-axis.

required
y str

Column name for the y-axis.

required
hue str | None

Column name for grouping into separate series.

None
hue_order list | None

Explicit order for hue levels.

None
estimator Expr | None

Aggregation expression (narwhals Expr). Defaults to mean.

None
color str | None

Single colour for the line (CSS colour string).

None
palette list | None

List of colours, one per hue level.

None

Returns:

Name Type Description
XYChart XYChart

An instance ready to render or further configure.

Raises:

Type Description
ValueError

If a required column is missing or numeric x values are not evenly spaced.