curve

A curve on a graph: a function, an equation, or a position in t.

curveNode
Only withxyargandpolarxyzplane
On this page
A blue parabola and a teal sine wave crossing it.A blue parabola and a teal sine wave crossing it.

#A function of x

curve(f: x^2) plots y as a function of x. On the polar plane the function is of theta and gives r: curve(f: 1 + cos(theta)) is a cardioid. Any other letter in the expression is a parameter, so a * sin(b * x) moves as the reader drags a and b. A function in pieces is one expression built with min, max and clamp: min(2x, 10) rises and then holds at 10, and stays one curve, with one max and min, under any parameter.

#An equation

Written with =, a curve is the set of points where its two sides agree, in both of the plane's coordinates: curve(f: x^2 + y^2 = 4) is a circle, curve(f: x = y^2) a parabola on its side, and curve(f: r = 1 + cos(theta)) the cardioid again. Nothing has to be solved for y first. An equation has no direction, so its ends carry no arrowheads or dots. The ordinary and polar planes take equations; the argand plane and space do not.

#A position in t

A curve may instead be a position in t, with the interval t runs over: curve(x: cos(t); y: sin(t); t: [0, 2pi]). On the argand plane the position is z:, on the polar plane r: and theta:, and in space x:, y: and z:. On the argand plane and in space it is the only form:

graph:argand{
    curve(z: cos(t) + i sin(t); t: [0, 2pi])
}

A function of x is refused there:

graph:argand{
    curve(f: x^2)
}

[semantic]'curve: f' needs a dependent axis over an independent one, and the argand plane has none — write a position in t (z: t: [a, b])

A path in t can enclose a region, and fill-style shades it: solid, hatched or dotted, where the default, outlined, leaves it empty. A closed loop fills itself; an arc closes straight across its chord, and close: names a point the region passes through first, so an arc closed through its centre is a sector. A function of x encloses nothing, and refuses any fill-style but outlined; the area under it is an integral. stroke-style draws the curve itself solid, dashed or dotted.

graph{
    curve(x: 2 * cos(t); y: 2 * sin(t); t: [0, pi/3]; fill-style: solid; close: (0, 0))
}(
    aspect: equal
)

#Domains and ends

domain: limits the x a function is drawn over and range: the y; both stop the curve where it crosses them. Where a curve runs off the frame its end is an arrowhead, and where a domain or range stops it the end is a dot, filled at a closed end, [0, 2], and hollow at an open one, (0, 2). !endpoints leaves both off. A curve's max and min are taken over the domain it is drawn on. Given an id, curve#flight, a curve is a path a cue.trace can follow.


#Attributes

On any plane
tAnimatable
The interval the parametric variable runs over — [0, 2pi], ends parametised. Required with the parametric coordinates; not with expression.
colour
Curve colour.
colour-along-curve
Also written: color
Defaultblue
width
Stroke width.
width-along-curve
Default2
stroke-style
How the curve is drawn: solid, dashed or dotted. A function of the point it is at — its x and y, its t on a curve in t, its r and theta on the polar plane — so it may change along the curve: stroke-style: y -> (..<0: dashed; 0..: solid).
stroke-along-curve
Defaultsolid
fill-styleAnimatable
How the region a curve in t encloses is filled — solid, hatched, dotted, or outlined, no shading — one value for the whole region. A y(x) curve shades nothing; the area under a function is integral.
solidhatcheddottedoutlined
Defaultoutlined
closeAnimatable
A point the shaded region comes back through before it closes, as a coordinate pair. An arc closed through the centre of its circle is a sector — the wedge no other mark can draw, since polygon has straight sides and integral closes to the axis. Nothing where fill-style is outlined.
Also written: close-at
domainAnimatable
The x interval a function is drawn over. It stops at each end with a dot: filled for a closed end, [0, 2], hollow for an open one, (0, 2).
rangeAnimatable
The y interval a function is drawn within. It stops where it crosses either end, with a dot as at a domain's end.
endpointsAnimatable
Endpoint decoration: an arrow where the curve runs on past the frame, and a dot where its domain stops it — filled for a closed end, open for an open one. Holes in the function are marked either way.
Defaulttrue
label
Text drawn beside the element — rich text, so $maths$ and inline formatting render. Fades and draws with the element.
hiddenAnimatable
Declared but not drawn. Animatable — hidden: true !cue.to{false}(at: 2) reveals it — and unlike a cue, a hidden element still frames the plot, so the axes do not jump when it appears.
Defaultfalse
lock
Keeps the reader from editing this element on an editable: graph. Nothing at all on a graph that is not editable.
Also written: locked
Defaultfalse
text-sizeAnimatable
Text size.
Default20
layerAnimatable
Paint order among the marks: a higher layer is drawn later, on top; equal or omitted, the marks stack in document order, later on top.
group
The groups this mark belongs to, comma-separated: group: 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.
Only withxyplane
expressionImplicitAnimatable
The curve. As an expression, a function of the plane's independent axis: y(x) on the ordinary plane, curve(f: x^2), and r(theta) on the polar one. As an equation, the points where its two sides agree, in the plane's two coordinates: curve(f: 2y = x), curve(f: x^2 + y^2 = 4), curve(f: r = 1 + cos(theta)). The argand plane takes neither — write a position in t there. Not with the parametric coordinates.
Also written: exp, f, func, functionCan be written as shorthand: curve:value
xAnimatable
A position in t: the x coordinate as an expression in t, with y: (and z: in space) and t: — curve(x: cos(t); y: sin(t); t: [0, 2pi]). Not with expression.
yAnimatable
A position in t: the y coordinate as an expression in t, with x: and t:.
Only withargandplane
zAnimatable
On the argand plane, the curve as z(t), a complex expression in t: curve(z: sqrt(13) * e^(i * t); t: [0, 2pi]). In space, the z coordinate as an expression in t, with x: and y:.
Only withpolarplane
expressionImplicitAnimatable
The curve. As an expression, a function of the plane's independent axis: y(x) on the ordinary plane, curve(f: x^2), and r(theta) on the polar one. As an equation, the points where its two sides agree, in the plane's two coordinates: curve(f: 2y = x), curve(f: x^2 + y^2 = 4), curve(f: r = 1 + cos(theta)). The argand plane takes neither — write a position in t there. Not with the parametric coordinates.
Also written: exp, f, func, functionCan be written as shorthand: curve:value
rAnimatable
On the polar plane, a position in t: the distance as an expression in t, with theta: and t:.
thetaAnimatable
On the polar plane, a position in t: the angle as an expression in t, with r: and t:.
Only withxyzplane
xAnimatable
A position in t: the x coordinate as an expression in t, with y: (and z: in space) and t: — curve(x: cos(t); y: sin(t); t: [0, 2pi]). Not with expression.
yAnimatable
A position in t: the y coordinate as an expression in t, with x: and t:.
zAnimatable
On the argand plane, the curve as z(t), a complex expression in t: curve(z: sqrt(13) * e^(i * t); t: [0, 2pi]). In space, the z coordinate as an expression in t, with x: and y:.

#Derived attributes

Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.

On any plane
lengthDerived
The arc length of what is drawn, in the plane's units: a y(x) curve over the same interval as max, a curve in t over its whole t: (in space too), a polar r(θ) over the theta window; holes add nothing. A dash for an equation, or where an axis is a log scale, names or dates.
Only withxyplane
maxDerived
The largest value a y(x) curve takes over its own domain (the visible window where that is unbounded), within any range:, tracking parameters live; a dash for a curve in t, an equation, or a domain with no value in it.
minDerived
The smallest value a y(x) curve takes over the same interval; a dash where max is.
max-xDerived
The x at which a y(x) curve first reaches max; a dash where max is.
min-xDerived
The x at which a y(x) curve first reaches min; a dash where min is.

#Allowed in

#Examples

A blue parabola.A blue parabola.
graph{
    curve(expression: x^2; colour: blue)
}
One period of a sine wave, from −π to π, a filled dot at each end where its domain stops it.One period of a sine wave, from −π to π, a filled dot at each end where its domain stops it.
graph{
    curve(expression: sin(x); domain: [-pi, pi])
}
In space: the helix (2 cos t, 2 sin t, t/2) climbing twice round the z axis.In space: the helix (2 cos t, 2 sin t, t/2) climbing twice round the z axis.
graph:xyz{
    curve(x: 2 * cos(t); y: 2 * sin(t); z: t / 2; t: [0, 4pi]; colour: red)
}(
    x domain: [-3, 3]
    y domain: [-3, 3]
    z domain: [0, 7]
)
Three curves written as equations: the line 2y = x, the circle x² + y² = 4, and the sideways parabola x = y² − 2.Three curves written as equations: the line 2y = x, the circle x² + y² = 4, and the sideways parabola x = y² − 2.
graph{
    curve(f: 2y = x; colour: blue)
    curve(f: x^2 + y^2 = 4; colour: purple)
    curve(f: x = y^2 - 2; colour: orange)
}(
    x domain: [-4.5, 4.5]
    y domain: [-3, 3]
    aspect: equal
)

#Notes

  • Give a curve a node id — curve#flight(f: …) — to let cue.trace follow it with path: #flight.

Last updated