fit
A least-squares fit through the observations of the scatter named in of:, and no others — a graph may carry two fits over two scatters. model chooses the family and degree the polynomial degree; giving degree a parameter rather than a number puts the degree under the reader's control through that parameter's slider. Publishes derived slope, intercept and r2.
Only withplane
Writing with it:Reading computed values in prose
#Attributes
Also written: through, dataThe scatter to fit, by its id —
fit(of: #readings). The fit is taken through that mark's observations alone, so two scatters in one graph carry two independent fits. To fit part of a sample, draw that part as its own scatter and name it here.Can be written as shorthand: fit:valuemodel
Default
polynomialPolynomial degree — a number, or an expression of parameters (degree: d) when the reader should drive it through a parameter slider.
Default
1colour
Also written: colorCurve colour.
Default
tealDeclared 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.Default
false#Derived attributes
Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.
slope
intercept
r2
#Allowed in
#Examples
fit(of: #readings; model: polynomial; degree: d; colour: teal)scatter#all(x: #trial.dose; y: #trial.response)
scatter#typical(x: #clean.dose; y: #clean.response)
fit#with-outlier(of: #all; degree: 1; colour: grey)
fit#without(of: #typical; degree: 1; colour: blue)