segment

A straight line between two points, stopping at both.

segmentNode
On this page
Two line segments, one rising from the origin and one grey segment falling across it.Two line segments, one rising from the origin and one grey segment falling across it.

A segment is the straight line between two points, segment(start: (0, 0); end: (2, 1)), stopping at both. Animated, end: (2, 1) !cue.to{(4, 3)}(at: 1) moves the end in a straight line; width animates the same way. ticks draws congruence hatches across its middle: segments with the same number are the same length, as an angle's arcs mark equal angles. style is its stroke, solid, dashed or dotted; a dashed segment draws a line that is not part of the figure itself, such as a construction line or where a side stood before it moved.

start and end each take a written point or a list of points another mark publishes, such as a fit's #trend.fitted and #trend.readings. Two lists pair item by item as far as the shorter goes, one segment to each pair; a written point against a list fans out to every point in it.

segment(start: #trend.fitted; end: #trend.readings; colour: orange; style: dashed)

colour is per segment: one colour for all of them, a list, or a list of numbers applied to colours, #trend.residuals -> (..<0: blue; 0..: red). It is fixed once drawn, and takes no !cue.to.


#Attributes

startRequiredImplicitAnimatable
One end, as a coordinate pair: start: (2, 1), or (x, y, z) in space. Animatable as a whole, so !cue.to{(4, 3)} moves the end in a straight line.
segment-end
Also written: fromCan be written as shorthand: segment:value
endRequiredAnimatable
The other endpoint, e.g. end: (6, 9).
segment-end
Also written: to
colour
Colour.
colour-style
Also written: color
Defaultgrey
widthAnimatable
Stroke width.
Default2
opacityAnimatable
Opacity.
Default1
styleAnimatable
How the segment is drawn: solid, dashed or dotted. One value for the whole segment.
soliddasheddotted
Defaultsolid
ticksAnimatable
Congruence hatches across the middle of the segment: one, two or three. Segments with the same number of ticks are the same length, as an angle's arcs mark equal angles.
Default0
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.

#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 distance from start to end in the plane's units (in space, the box's); a dash where an axis is a log scale, names or dates, or an end does not resolve.
Only withxyplane
angleDerived
The segment's direction from start to end, in degrees anticlockwise from the positive x axis, in [0, 360); a dash where length is a dash, or for a segment of no length.
Only withargandplane
angleDerived
The segment's direction from start to end, in degrees anticlockwise from the positive x axis, in [0, 360); a dash where length is a dash, or for a segment of no length.
Only withpolarplane
angleDerived
The segment's direction from start to end, in degrees anticlockwise from the positive x axis, in [0, 360); a dash where length is a dash, or for a segment of no length.

#Allowed in

#Examples

A line segment from the origin to (2, 1).A line segment from the origin to (2, 1).
graph{
    segment(start: (0, 0); end: (2, 1))
}(
    x-domain: [-1, 3]
    y-domain: [-1, 2]
)
An isosceles triangle drawn as three segments, its two equal sides each crossed by one congruence tick and its base by none.An isosceles triangle drawn as three segments, its two equal sides each crossed by one congruence tick and its base by none.
graph{
    segment(start: (0, 0); end: (2, 3); ticks: 1)
    segment(start: (2, 3); end: (4, 0); ticks: 1)
    segment(start: (0, 0); end: (4, 0))
}
In space: the three edges of a tetrahedron that meet at the origin, and the three that close its far face, dashed.In space: the three edges of a tetrahedron that meet at the origin, and the three that close its far face, dashed.
graph:xyz{
    segment(start: (0, 0, 0); end: (2, 0, 0))
    segment(start: (0, 0, 0); end: (0, 2, 0))
    segment(start: (0, 0, 0); end: (0, 0, 2))
    segment(start: (2, 0, 0); end: (0, 2, 0); style: dashed)
    segment(start: (0, 2, 0); end: (0, 0, 2); style: dashed)
    segment(start: (0, 0, 2); end: (2, 0, 0); style: dashed)
}(
    x domain: [0, 2]
    y domain: [0, 2]
    z domain: [0, 2]
)

Last updated