line
Connects data points with a line. A line draws through a set of points, so it is most often paired with select() to trace a layout produced by another chart.
python
from gofish import Layer, chart, scatter, blank, select, line
Layer([
chart(catch_locations)
.flow(scatter(by="lake", x="x", y="y"))
.mark(blank().name("points")),
chart(select("points")).mark(line()),
]).render(w=500, h=300, axes=True)Signature
python
line(stroke=None, strokeWidth=None, opacity=None, interpolation=None) -> MarkParameters
| Parameter | Type | Description |
|---|---|---|
stroke | str | Line color |
strokeWidth | int | Line width in pixels |
opacity | float | Opacity, 0–1 |
interpolation | str | Curve interpolation, e.g. "linear", "monotone" |
Returns a Mark for use in .mark().
The line pattern
A line needs points to connect. The idiomatic recipe:
- One chart positions invisible
blankmarks and names the layer with.name("points"). - A second chart selects that layer —
chart(select("points"))— and draws aline()through it. Layer([...])composes the two.
This separation lets the same positioned points back both a line and, say, circles drawn on top.
Examples
python
# Styled line
chart(select("points")).mark(line(stroke="black", strokeWidth=2))