Manual
Overview
Language
IntroductionScenes & structureText & inlineGraphsCode panesAnimationDataReuse & logicExpressions & parameters
Elements
Text
ParagraphHeading 1Heading 2Heading 3Heading 4Unordered ListDivider
Media
ImageTableEquation
Callouts
NoteDefinitionExampleTask
Graph
GraphLinePolygonCurveIntegralScatterHistogramPointSegmentVectorCircleSquareRectangleTriangleStarDiamondHexagonTextAxis labelAxis BraceFitResidualsContourHeatmapParameter
Code
Code canvasLines
Animation
CueDraw cueTrace cueHighlight cueSpotlight cueType cue
Structure
SceneStep
Reference
Internote Reference
Inline
Formatting
BoldItalicsInline CodeHighlightLink
Text colour
Red textOrange textYellow textGreen textTeal textBlue textPurple textPink textGrey text
Maths
Maths
Reference
Internote ReferenceValueConstant
Other
FootnoteIcon
Directives
DatasetIncludeConstantsTemplatePresetConditionalForIgnore
Keyframes
KeyframeZoom keyframe
Attribute types
?
  1. Elements
  2. Graph
  3. Fit

Fit

fitBlock elementGraph

A least-squares fit over the graph's scatter data — the model family and degree range are authored; the reader drives the degree with a native control in the pane footer.

Attributes

modelImplicit
fit-model
Model family: polynomial or linear.The head shorthand supplies it: fit:value
Defaultpolynomial
degree
number
Polynomial degree — a number, or an expression of parameters (degree: d) when the reader should drive it through a parameter slider.
Default1
colour
colour
Also written: colorCurve colour.
Defaultteal
width
number
Stroke width.
Default2
hidden
boolean
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
boolean
Also written: lockedKeeps the reader from editing this element on an `editable:` graph. Nothing at all on a graph that is not editable.
Defaultfalse

Derived attributes

Computed while the element renders — read one with #id.name in attribute position or !value:#id.name() in prose, never set.

slopeDerived
The x¹ coefficient of the current fit — live under the reader-draggable degree.
interceptDerived
The constant term of the current fit.
r2Derived
The coefficient of determination of the current fit against the pane's scatter data.

Allowed in

canvas.graph { }cue { }cue.draw { }cue.trace { }cue.highlight { }cue.spotlight { }

Examples

fit(model: polynomial; degree: d; colour: teal)
On this page
AttributesDerived attributesAllowed inExamples
Fit · Internote