plot
plot(y)/plot(x, y)/plot(x, y, "o")
Input: y · Output: no output
What it is
Draws a basic line (or, with a positional or marker= marker string such as "o", a scatter-style) plot of y versus x. x and y are equal-length Vecs (or scalars broadcast to match) of numbers, data units; omitting x uses 0, 1, 2, ....
Overloads
plot's three call shapes are the most common overload in this chapter, and the marker-string form genuinely changes what gets drawn — a connected line versus discrete, unconnected points — not just its color or width.
y can be Vec or string; x can be Vec or string.
3 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.
| Code | Input | Output | Description |
plot(y) | y Vecnot documented yet | no output | Look for a jagged line with no meaningful x-axis units. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
plot([3, 1, 4, 1, 5]) # x defaults to 0, 1, 2, 3, 4
· plot: figure 9 (5 points)
| Code | Input | Output | Description |
plot(x, y) | x Vecx and y are equal-length Vecs (or scalars broadcast to match) of numbers, data units.y VecDraws a basic line (or, with a positional or marker= marker string such as "o", a scatter-style) plot of y versus x. | no output | With two equal-length Vecs it draws the default connected line. Look for a smooth curve with no dots at the sample points. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
x = 0 to 9
plot(x, sin(x / 2))
· plot: figure 10 (10 points)
| Code | Input | Output | Description |
plot(x, y, "o") | x stringx and y are equal-length Vecs (or scalars broadcast to match) of numbers, data units.y stringDraws a basic line (or, with a positional or marker= marker string such as "o", a scatter-style) plot of y versus x."o" stringA third positional string like "o" (or marker="o") switches the exact same call to unconnected dots instead of a line. | no output | Look for discrete points with no line joining them. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
x = 0 to 9
plot(x, sin(x / 2), "o")
· plot: figure 11 (10 points)
How it works
stair is the only callable spelling: step is already a reserved keyword (to ... step ... ranges), so step(...) can't be a function call — it lexes as a keyword, not an identifier. The rendered marker is internally still "step".
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.