Tables
table { … } becomes a Desmos table: one entry per column, each a name and its values. The first column is the x values; the rest plot against it, and each carries its own styling, written after it the way a statement’s is.
"Tables"
// Written out, one column per line.table { x = [1, 2, 3, 4, 5] y = [2, 4, 8, 16, 32] @ color: RED}
// Or inline, with a ; between the columns - the two forms compile identically.table { x = [0, 1, 2, 3]; y = [0, 1, 4, 9] @ color: BLUE, lines }
// Each column carries its own styling.table { t = [0, 1, 2, 3, 4, 5] pos = [0, 5, 20, 45, 80, 125] @ color: GREEN, lines, lineStyle: DASHED vel = [0, 10, 20, 30, 40, 50] @ color: ORANGE, pointStyle: OPEN, pointSize: 12}
// A column with no values is a computed one: it evaluates the expression// against the column before it.table { u = [-3, -2, -1, 0, 1, 2, 3] u ^ 2 @ color: PURPLE u ^ 3 @ color: RED, hidden}
folder "Fitting a curve by eye" { "Drag the slider until the curve meets the data." k = 1 @ slider: 0..3 step 0.05 y = k * x ^ 2 @ color: BLUE, lineWidth: 3}
folder "A line of best fit" { "~ fits a model's parameters to data: here a slope m and an intercept b. The residuals go in e1." table { x2 = [1, 2, 3, 4, 5, 6] @ hidden y2 = [2.1, 3.9, 6.2, 7.8, 10.1, 12.2] @ color: BLUE, pointSize: 12 } "A cell left blank is an empty slot; its row draws no point." table { x4 = [1, 2, 3, 4] y4 = [3, , 5, 6] @ color: GREEN } y2 ~ m x2 + b @ color: BLUE, residuals: e1 "An exponential fitted in log space, which suits data that grows by a factor." y3 = [1.1, 2.1, 3.9, 8.2, 15.8, 32.5] @ hidden y3 ~ a c ^ x2 @ color: RED, logMode}Open in playground →