Contents Previous Next Subchapters

Line Plots Using One Command
Syntax plotcmd(y)
plotcmd(xy)
plotcmd(xys)
plotcmd(x1y1s1x2y2s2... )
Where plotcmd is plot, loglog, semilogx, or semilogy
See Also gplot , axis , gstyle

Description
Clears the current graphics viewport and then plots one or more x-y curves in the viewport with the following scaling:
plotcmd x scaling y scaling
plot linear linear
loglog log log
semilogx log linear
semilogy linear log
If you enter
     x = seq(4) - 1
     y = 10^x
     plot(x, y, "x")
O-Matrix will draw crosses at the points (0, 1), (1, 10), (2, 100), and (3, 1000), using linear scaling for both the x and y axis. If you continue by entering
     semilogy(x, y, "x")
O-Matrix will draw crosses at the same points but with the x-axis linear scaled and the y-axis log scaled.

x and y Argument Types
The arguments x, and y can be integer, real or double-precision matrices. In the one argument syntax, the argument y can be complex.

Plotcmd(y)
If y is complex, this is equivalent to the syntax
     
plotcmd(double(y), imag(y))
If you enter
     theta = 0. : .1 : (2 * pi + .1)
     y     = 1r0 * cos(theta) + 1i0 * sin(theta)
     plot(y)
O-Matrix will plot a circle.

If y is integer, real, or double-precision vector of length m, this plots one curve corresponding to the x-y values
     (iy(i)), i = 1 , ... , m
If you enter
     y  = (seq(11) - 6)^2
     plot(y)
O-Matrix will plot a parabola. If y is not complex or a vector, for each j between 1 and the column dimension of y this plots a curve corresponding to the x-y values
     (iy(ij)), i = 1 , ... , m
where m is the row dimension of y If you enter
     y = [ seq(10), 2 * seq(10)]
     plot(y)
O-Matrix will plot the lines y = x and y = 2 * x.

Plotcmd(x, y) with x a Vector
If m is the length of vector x, either the row or column dimension of y must also be m.

If m is the row dimension of y, for each j between 1 and the column dimension of y this plots a curve corresponding to the x-y values
     (x(i), y(ij)), i = 1 , ... , m
If you enter
     x = 0. : .1 : (2 * pi + .1)
     y = [sin(x), cos(x)]
     plot(x, y)
O-Matrix will plot one cycle of the sine and cosine functions.

If m is the column dimension of y, for each i between 1 and the row dimension of y this plots a curve corresponding to the x-y values
     (x(j), y(ij)), j = 1 , ... , m
If you continue the example above by entering of the following lines:
     plot(x, y)
     plot(x', y)
     plot(x, y')
     plot(x', y')
O-Matrix will redraw the same plot.

Plotcmd(x, y) with y a Vector
If m is the length of the vector y, either the row or column dimension of x must also be m. If m is the row dimension of x, for each j between 1 and the column dimension of x this plots a curve corresponding to the x-y values
     (x(ij), y(i)), i = 1 , ... , m
If m is the column dimension of x, for each i between 1 and the row dimension of x this plots a curve corresponding to the x-y values
     (x(ij), y(j)), j = 1 , ... , m

Plotcmd(x, y) Neither a Vector
If neither x or y is a vector, their dimensions must be equal. In this case, for each j between 1 and the column dimension of x this plots a curve corresponding to the x-y values
     (x(ij), y(ij)), i = 1 , ... , m
where m is the column dimension of x. If you enter
     theta = 0. : .1 : 2 * pi + .05
     x = [cos(theta) - 1, cos(theta), cos(theta) + 1]
     y = [sin(theta) - 1, sin(theta), sin(theta) + 1]
     plot(x, y)
O-Matrix will plot three circles with centers at (1, 1), (0, 0) and (-1, -1).

Plotcmd(x, y, s)
The argument s is a character row vector specifying the style with which each of the curves is plotted. It may contain one of the following color codes
code Meaning
y yellow
m magenta
c cyan
r red
g green
b blue
w white
k black
If you enter
     x = seq(5)
     y = x
     s = "g"
     plot(x, y, s)
O-Matrix will draw a green line. If a color is not specified for a plot, a color is chosen from the list above with black coming first and the color white omitted.

The argument s may contain one of the following symbol codes
code Meaning
. dot
o circle
x cross
+ plus
* star
s square
d diamond
^
triangle
If a symbol code is present, the corresponding symbol is plotted at each x-y pair. If you enter
     x = seq(5)
     y = x
     s = "g+"
     plot(x, y, s)
O-Matrix will plot green plus signs at the points (i,i) for i = 1, 2, 3, 4, 5.

The argument s may contain one of the following line styles
code Meaning
- solid
: dotted
-- dashed
If a line type is present, the x-y pairs are connected by the specified type of line. If you enter
     x = seq(5)
     y = x
     s = "r+-"
     plot(x, y, s)
O-Matrix will plot red plus signs at the points (i,i) for i = 1, 2, 3, 4, 5 and a red line connecting the points.

Plotcmd(x1, y1, s1, x2, y2, s2, ... )
The line plots specified by plotcmd(x1y1s1), plotcmd(x2y2s2), ... , are all included in the current plotting window. If you enter
     x = seq(5)
     y = x
     plot(x, y, "", x, y + 1, "g", x, y + 2, "")
O-Matrix will plot a black line, then a green line above the black line, and then a blue line above the green line. (Note black is the default for the first color and the color blue comes after green in the list of colors above.)