Skip to content

Basics

An Axis file is a list of statements, one per line. Each becomes one expression in the graph, in the order it is written.

examples/01-basics.axis

"Basics"
// A // starts a comment, which runs to the end of the line. It never reaches
// the graph.
// A bare string on its own line is a note - the yellow text card in Desmos.
"Notes explain a graph to whoever opens it next."
// An equation is graphed.
y = 2x + 1
// A definition names a value. Referring to it below re-uses it.
c = 3
y = c * x - 4
// A newline ends a statement, and so does a ;, so two short ones may share a
// line.
d = -2; y = d * x + 6
// Anything after an @ is metadata: how the statement should look and behave.
y = x ^ 2 @ color: #c74440
// Several properties are separated by commas.
y = x ^ 3 @ color: #2d70b3, lineWidth: 4, lineOpacity: 0.6
// Where there are more of them than sit comfortably behind an @, an @{ } block
// gives them a line each - and inside it the newline is the separator. A colour
// may be a hex literal, as above, or one of the Desmos palette's own by name:
// RED, BLUE, GREEN, PURPLE, ORANGE or BLACK.
y = x ^ 4 @{
color: GREEN
lineWidth: 4
lineStyle: DASHED
label: "quartic"
showLabel: true
}
// A statement may span lines while a bracket is open.
P = [
(-2, 4),
(0, 0),
(2, 4)
] @ color: GREEN, pointSize: 14
// hidden keeps a statement in the list but off the graph; it is still defined
// and usable. It is written bare, with no value: any property that is true or
// false may be, and a bare one means true.
k = 10 @ hidden
// secret hides it from the expression list entirely.
scale = 0.5 @ secret
y = k * sin(scale * x) @ color: PURPLE
Open in playground →