Qu

plot

Builtin index · Plotting

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.

CodeInputOutputDescription
plot(y)
y Vecnot documented yet
no outputLook 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

output
· plot: figure 9 (5 points)
1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Styled panel
CodeInputOutputDescription
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 outputWith 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))
output
· plot: figure 10 (10 points)
-1 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 Styled panel
CodeInputOutputDescription
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 outputLook 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")
output
· plot: figure 11 (10 points)
-1 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 x=0, y=0 x=1, y=0.479 x=2, y=0.841 x=3, y=0.997 x=4, y=0.909 x=5, y=0.598 x=6, y=0.141 x=7, y=-0.351 x=8, y=-0.757 x=9, y=-0.978 Styled panel

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.