polygon

A closed shape whose outline is its vertex series.

polygonNode
Only withxyargandpolarxyzplane
On this page
A filled regular pentagon and, beside it, a teal outlined regular hexagon.A filled regular pentagon and, beside it, a teal outlined regular hexagon.

#Attributes

On any plane
slice
The column this mark is SLICED by — long-format data, one row per thing per slice, showing the one the scene's parameter over that column holds. A column with a number line interpolates, so a reader stopped between two values sees half way; a column of names selects the rows carrying the name they picked.
colourAnimatable
Colour.
paint
Also written: color
Defaultteal
opacityAnimatable
Opacity.
Default1
fill-styleAnimatable
How the inside is filled: solid; hatched, ruled with diagonal lines over a pale wash of the colour; dotted, stippled with dots over the wash; or outlined, no fill, the edge alone.
solidhatcheddottedoutlined
Defaultsolid
stroke-styleAnimatable
How the edge is drawn: solid, dashed or dotted. An outlined, dashed polygon is the shape that is not there — where a figure was before it moved, a region a constraint rules out.
soliddasheddotted
Defaultsolid
interpolateAnimatable
How the outline gets from one vertex to the next: linear for straight sides, bezier for a closed round outline, on the same midpoint handles as the line’s. No step — a staircase is a reading against x, and a closed outline is not one.
linearbezier
Also written: interpolation
Defaultlinear
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
xImplicitAnimatable
The vertices' x coordinates, e.g. 0, 2, 1. Numbers or a dataset column; entries may be expressions of parameters.
Can be written as shorthand: polygon:value
yAnimatable
The vertices' y coordinates, paired with x by position.
Only withargandplane
zAnimatable
On the argand plane, the readings as complex numbers: written out (1 + i, 2 - i, -3i, a bare number a real), or a column of complex literals bound whole (#roots.z). Instead of re/im. In space, the vertices' z coordinates, paired with x and y by position.
reAnimatable
On the argand plane, the readings' real parts, one per reading — numbers written out or a column — paired with im by position.
imAnimatable
On the argand plane, the readings' imaginary parts, paired with re by position.
Only withpolarplane
rAnimatable
On the polar plane, the readings' distances from the origin, paired with theta by position.
thetaAnimatable
On the polar plane, the readings' angles in radians (60deg for degrees), paired with r by position; names on a categorical theta.
Only withxyzplane
xImplicitAnimatable
The vertices' x coordinates, e.g. 0, 2, 1. Numbers or a dataset column; entries may be expressions of parameters.
Can be written as shorthand: polygon:value
yAnimatable
The vertices' y coordinates, paired with x by position.
zAnimatable
On the argand plane, the readings as complex numbers: written out (1 + i, 2 - i, -3i, a bare number a real), or a column of complex literals bound whole (#roots.z). Instead of re/im. In space, the vertices' z coordinates, paired with x and y by position.

#Derived attributes

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

areaDerived
The area the outline encloses, in square units of the plane (or the box), rounded where interpolate: bezier rounds it; a dash with fewer than three vertices, or where an axis is a log scale, names or dates.
perimeterDerived
The length of the closed outline in the plane's units, rounded where interpolate: bezier rounds it; a dash where area is.

#Allowed in

#Examples

A filled triangle with corners at (0, 0), (2, 0) and (1, 2).A filled triangle with corners at (0, 0), (2, 0) and (1, 2).
graph{
    polygon(x: 0, 2, 1; y: 0, 0, 2)
}
A teal triangle drawn as an outline only.A teal triangle drawn as an outline only.
graph{
    polygon(x: -1, 1, 0; y: -1, -1, 1; fill-style: outlined; colour: teal)
}
In space: the triangle with corners (2, 0, 0), (0, 2, 0) and (0, 0, 2), the face the plane x + y + z = 2 cuts off the first octant.In space: the triangle with corners (2, 0, 0), (0, 2, 0) and (0, 0, 2), the face the plane x + y + z = 2 cuts off the first octant.
graph:xyz{
    polygon(x: 2, 0, 0; y: 0, 2, 0; z: 0, 0, 2; colour: purple)
}(
    x domain: [0, 2]
    y domain: [0, 2]
    z domain: [0, 2]
    aspect: equal
)

#Notes

  • In space the face is filled and shaded as the surface it spans.

Last updated