line
A path through readings in the order written.
linexyargandpolarxyzplane

A line joins readings in the order written: x: and y: paired by position, numbers or dataset columns, line(x: #co2.year; y: #co2.ppm). On the argand plane the readings are z: or re: and im:, on the polar plane r: and theta:, and in space x:, y: and z:. The number line takes no line. A derived window leaves no room past a line's first and last x, so a series runs from edge to edge. A series read as an amount, filled down to the baseline, is an area.
interpolate is how it gets from one reading to the next. linear joins them with straight legs. bezier rounds the corners with a cubic through every reading, its handles at the middles of the legs either side, so it cannot overshoot; it draws the quantity as varying smoothly between readings. step holds each value until the next x and then jumps, with a dot at each jump, filled where the value is taken and hollow where it is left; !endpoints drops the dots and risers draws the vertical joins. polygon takes linear and bezier.
slice: draws long-format data, one row per thing per moment, as the rows a parameter over that column holds: between two numeric values the line is interpolated, and over a column of names it shows the rows carrying the name picked.
error is each reading's uncertainty in y, written as a scatter's is: a half-width per reading, or the interval's two ends, error: #growth.lo .. #growth.hi. error-style draws it as a capped bar at every reading (bars, the default) or as a band washed between the ends, which reads as an interval round the whole series where a bar at every reading would be a comb. A reading with no entry breaks the band.


graph{
@data#growth{
week | height | lo | hi
0 | 1.0 | 0.9 | 1.1
1 | 1.8 | 1.6 | 2.0
2 | 3.1 | 2.7 | 3.5
3 | 4.6 | 4.0 | 5.2
4 | 6.4 | 5.5 | 7.3
5 | 8.0 | 6.8 | 9.2
6 | 9.3 | 7.8 | 10.8
7 | 10.1 | 8.4 | 11.8
8 | 10.6 | 8.7 | 12.5
}
line(x: #growth.week; y: #growth.height; error: #growth.lo .. #growth.hi; error-style: band; colour: orange)
}(
x axis label: week
y axis label: height (cm)
)#Attributes
slicecolourcolour-alongcolorpinkwidthwidth-along2stylesolid, dashed or dotted. A function of the point it is at, so it may change along the line: style: x -> (..8: solid; 8..: dashed) dashes it from x = 8 on.stroke-alongsolidinterpolatelinear joins them straight; bezier rounds the corners with a cubic through every reading, its handles at the middles of the legs either side, so it cannot overshoot; step holds each value until the next x and then jumps.linearstepbezierinterpolationlinearstep-endpointstruemarkersscatter draws its own, so the line and the readings it joins are one mark. Each marker's look is set by marker-shape, marker-size, marker-colour and marker-opacity.falsemarker-shape#self.value: marker-shape: #wheat.kind -> (measured: circle; projected: diamond).shape-stylecirclemarker-sizescatter's markers take: one size, a list reading by reading, or an expression giving one per reading.size-style6marker-colour#self.value. Unwritten, each marker takes the line's own colour at its reading.colour-stylemarker-colormarker-opacityopacity-style1risersconnectfalselabel$maths$ sets.hiddenfalselocklockedfalsetext-size20layergroupgroup: Early sown, Projected. It is drawn in the colour of the first that has one and the style of the first the graph's key: gives one, unless it writes its own colour: or style, and the footer's key names every group.xyplanex0, 1, 2 — entries may be expressions of parameters), or a dataset column (#co2.year). A column of names reads against a categorical axis (x format:, or the axis’s auto rule); an ISO date column reads as fractional years (2024-03-15 → ≈2024.2), and auto labels them in years. Paired with y by position.line:valueyx by position.byline(y: #scores.school; x: #scores.score; by: #scores.school; markers) is a dumbbell chart, and line(x: #scores.term; y: #scores.score; by: #scores.school) a slope chart. Each reading keeps its row, so a style applied to a column reads the right one.foldheads: end and a colour along the value axis, it is the switchback chart of a margin moving from one election to the next.falseheadsvector and a curve draw, its tip on the reading and the stroke stopped where it begins. A reading under a head takes no marker, and a leg shorter than the head takes a smaller one.nonestartendbothnoneerrorerror: #fit.lo .. #fit.hi — as a scatter's error: takes. Drawn as error-style: says.error-styleerror: is drawn: a capped bar at every reading, or a band washed between the low and high ends — the confidence band round a dense series, where a bar at every reading would be a comb. A reading with no error breaks the band.barsbandbarsargandplanez1 + i, 2 - i, -3i, a bare number a real), or a column of complex literals bound whole (#roots.z). Instead of re/im.reim by position.imre by position.errorerror: #fit.lo .. #fit.hi — as a scatter's error: takes. Drawn as error-style: says.error-styleerror: is drawn: a capped bar at every reading, or a band washed between the low and high ends — the confidence band round a dense series, where a bar at every reading would be a comb. A reading with no error breaks the band.barsbandbarspolarplanexyzplanex0, 1, 2 — entries may be expressions of parameters), or a dataset column (#co2.year). A column of names reads against a categorical axis (x format:, or the axis’s auto rule); an ISO date column reads as fractional years (2024-03-15 → ≈2024.2), and auto labels them in years. Paired with y by position.line:valueyx by position.z1 + i, 2 - i, -3i, a bare number a real), or a column of complex literals bound whole (#roots.z). Instead of re/im.#Derived attributes
Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.
value#self.value: marker-colour: #self.value -> (..<0: red; 0..: teal).xyplanemaxminmax is.max-xmax; a dash where max is, or where the x axis holds names.min-xmin; a dash where min is, or where the x axis holds names.xyzplanemaxminmax is.#Allowed in
#Examples


graph{
line(x: 0, 2, 4; y: 0, 2, 1; colour: pink)
}

graph{
line(x: 0, 1, 2; y: 0, 0.5, 1; interpolate: step)
}

graph{
line(x: #co2.year; y: #co2.ppm)
}

graph{
line(
x: 0, 1, 2, 3, 4, 5
y: -2, -1, 1, 0.5, 2, 3
markers
marker-shape: #self.value -> (..<0: circle; otherwise: diamond)
marker-size: 8
)
}

graph:xyz{
line(x: 2, 0, -2, 0, 2, 0; y: 0, 2, 0, -2, 0, 2; z: 0, 1, 2, 3, 4, 5; markers)
}(
x domain: [-3, 3]
y domain: [-3, 3]
z domain: [0, 5]
)#Writing guidance
- Framing a readable graph — When to write a domain, the defaults left alone, naming a series, the ticks the prose reads, and one meaning per hue.