contour

The level sets of a function of the plane.

contourNode
Only withxyargandpolarxyzplane
On this page
Eight concentric contour rings around the point (2, 3).Eight concentric contour rings around the point (2, 3).

A contour draws the level sets of a function of the plane, the same expression a surface takes, sampled over the visible window and again as the reader pans: contour(f: x^2 + y^2; levels: 1, 4, 9). levels: gives the values exactly, one curve each, and its entries may be parameters, levels: k, 2 * k. Without it, level-count: asks for about that many, 12 unless written, at round values the way ticks are chosen. In the expression the plane's coordinates are axes, not parameters: only the other letters get footer sliders, and moving one moves the levels live.

Under multicolour, the default, each level is drawn in the colour of its own value, violet low to red high; temperature runs blue through white to red; a hue draws every level alike. The colours span the values in the window, or the window colour: #self.value -> -1..1 -> temperature pins, which holds them still as a parameter moves. A map paints each level flat in the colour of the band its value falls in: colour: #self.value -> (..<0: blue; 0..: red). Over a surface of the same expression the levels trace the wash. In space they are drawn on the floor of the box, or on the surface at their own heights with on: surface.


#Attributes

expressionRequiredImplicitAnimatable
The function whose level sets are drawn, in the plane's coordinates: x and y on the ordinary plane, contour(f: (x - 2)^2 + (y - 3)^2); r and theta on the polar plane; z on the argand plane. In space, a height z = f(x, y).
Also written: exp, f, func, functionCan be written as shorthand: contour:value
level-countAnimatable
About how many level sets to draw, at round values of the function, the way axis ticks are chosen. Not read where levels: names them.
Default12
levelsAnimatable
The exact level values, overriding level-count:, for surfaces whose structure even spacing misrepresents — a quadratic bowl wants 1, 4, 9, 16. Entries are parametised: at: k, 2 * k, 4 * k rides a parameter slider. One entry is one curve: levels: 0.
onAnimatable
In space, where the level curves are drawn: floor (the default) maps them on the floor of the box under the surface; surface draws each on the surface at its own height. Space only.
floorsurface
Defaultfloor
colour
multicolour (the default) strokes each level along the full spectrum by its own value, violet low to red high; temperature is the blue → white → red ramp; a hue runs the rings pale to deep. Both ramps are fixed colours, identical in light and dark mode. A list of hues is the ramp's stops, low end first. The ramp spans the levels drawn, which shifts as a parameter moves them; applying #self.value, each level's value, pins the window so a level's colour says the same value from step to step: colour: #self.value -> 0..16 -> temperature. A map paints each level flat in its key's colour.
value-colour-style
Also written: color
Defaultmulticolour
widthAnimatable
Stroke width.
Default1.5
styleAnimatable
How the contour lines are drawn: solid, dashed or dotted. One value for every level.
soliddasheddotted
Defaultsolid
opacityAnimatable
How heavy the lines sit over the marks beneath them.
Default1
hiddenAnimatable
Declared but not drawn — animatable, so hidden: true !cue.to{false}(at: 2) is its reveal.
Defaultfalse
lock
A reader may not edit it on an editable graph.
Also written: locked
Defaultfalse
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.

#Derived attributes

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

valueDerived
The value of each level drawn, which colour: follows as #self.value: colour: #self.value -> -1..1 -> temperature pins the window the ramp spans, and a map paints each level flat.
minDerived
The smallest value the surface takes over the sampled window — for a loss surface, the number the whole picture is about. Cite it with {{#id.min}}.
maxDerived
The largest value the surface takes over the sampled window.

#Allowed in

#Examples

Teal contours of the saddle x² − y² at −4, −1, 0, 1 and 4: two families of hyperbolas crossing at the origin.Teal contours of the saddle x² − y² at −4, −1, 0, 1 and 4: two families of hyperbolas crossing at the origin.
graph{
    contour(expression: x^2 - y^2; levels: -4, -1, 0, 1, 4; colour: teal)
}(
    x-domain: [-4, 4]
    y-domain: [-4, 4]
)
Four circles about the origin at levels 1, 2, 4 and 8, each further from the last.Four circles about the origin at levels 1, 2, 4 and 8, each further from the last.
graph{
    contour(expression: x^2 + y^2; levels: 1, 2, 4, 8)
}(
    x-domain: [-4, 4]
    y-domain: [-4, 4]
)
Fourteen contours of sin x · cos y on the blue-to-red temperature ramp, closed rings around each peak and trough.Fourteen contours of sin x · cos y on the blue-to-red temperature ramp, closed rings around each peak and trough.
graph{
    contour(expression: sin(x) * cos(y); level count: 14; colour: temperature)
}
In space: the hill z = 9 − x² − y², faint, with its level curves drawn on the floor beneath it as a map, and again on the hill itself.In space: the hill z = 9 − x² − y², faint, with its level curves drawn on the floor beneath it as a map, and again on the hill itself.
graph:xyz{
    surface(expression: 9 - x^2 - y^2; opacity: 0.25)
    contour(expression: 9 - x^2 - y^2; level count: 6)
    contour(expression: 9 - x^2 - y^2; level count: 6; on: surface)
}(
    x domain: [-3, 3]
    y domain: [-3, 3]
    z domain: [0, 9]
)

Last updated