The Matlab-style two-dimensional plotting commands are:
This function produces two-dimensional plots. Many different combinations of arguments are possible. The simplest form isplot (y)
where the argument is taken as the set of y coordinates and the x coordinates are taken to be the indices of the elements, starting with 1.
If more than one argument is given, they are interpreted asplot (x, y, fmt ...)
where y and fmt are optional, and any number of argument sets may appear. The x and y values are interpreted as follows:
- If a single data argument is supplied, it is taken as the set of y coordinates and the x coordinates are taken to be the indices of the elements, starting with 1.
- If the first argument is a vector and the second is a matrix, the the vector is plotted versus the columns (or rows) of the matrix. (using whichever combination matches, with columns tried first.)
- If the first argument is a matrix and the second is a vector, the the columns (or rows) of the matrix are plotted versus the vector. (using whichever combination matches, with columns tried first.)
- If both arguments are vectors, the elements of y are plotted versus the elements of x.
- If both arguments are matrices, the columns of y are plotted versus the columns of x. In this case, both matrices must have the same number of rows and columns and no attempt is made to transpose the arguments to make the number of rows match.
If both arguments are scalars, a single point is plotted.
If the fmt argument is supplied, it is interpreted as follows. If fmt is missing, the default gnuplot line style is assumed.
- Set lines plot style (default).
- Set dots plot style.
- Set points plot style.
- Set linespoints plot style.
- Set impulses plot style.
- Set steps plot style.
- Interpreted as the plot color if n is an integer in the range 1 to 6.
- If nm is a two digit integer and m is an integer in the range 1 to 6, m is interpreted as the point style. This is only valid in combination with the
- If c is one of
"w", it is interpreted as the plot color (red, green, blue, magenta, cyan, or white).
"title"is the label for the key.
- Used in combination with the points or linespoints styles, set the point style.
The color line styles have the following meanings on terminals that support color.Number Gnuplot colors (lines)points style 1 red * 2 green + 3 blue o 4 magenta x 5 cyan house 6 brown there exists
The fmt argument can also be used to assign key titles. To do so, include the desired title between semi-colons after the formatting sequence described above, e.g. "+3;Key Title;" Note that the last semi-colon is required and will generate an error if it is left out.
Here are some plot examples:plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+")
This command will plot
ywith points of type 2 (displayed as `+') and color 1 (red),
y3with lines of color 4 (magenta) and
y4with points displayed as `+'.plot (b, "*")
This command will plot the data in the variable
bwill be plotted with points displayed as `*'.t = 0:0.1:6.3; plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);");
This will plot the cosine and sine functions and label them accordingly in the key.
Tell Octave to `hold' the current data on the plot when executing subsequent plotting commands. This allows you to execute a series of plot commands and have all the lines end up on the same figure. The default is for each new plot command to clear the plot device first. For example, the commandhold on
turns the hold state on. An argument of
offturns the hold state off, and
holdwith no arguments toggles the current hold state.
Return 1 if the next line will be added to the current plot, or 0 if the plot device will be cleared before drawing the next line.
Clear the plot window and any titles or axis labels. The name
clgis aliased to
clearplotfor compatibility with Matlab.
The commands gplot clear, gsplot clear, and replot clear are equivalent to
clearplot. (Previously, commands like gplot clear would evaluate
clearas an ordinary expression and clear all the visible variables.)
Close stream to the
gnuplotsubprocess. If you are using X11, this will close the plot window.
Delete the temporary files created by the plotting commands.
Octave creates temporary data files for
gnuplotand then sends commands to
gnuplotthrough a pipe. Octave will delete the temporary files on exit, but if you are doing a lot of plotting you may want to clean up in the middle of a session.
A future version of Octave will eliminate the need to use temporary files to hold the plot data.
Set axis limits for plots.
The argument limits should be a 2, 4, or 6 element vector. The first and second elements specify the lower and upper limits for the x axis. The third and fourth specify the limits for the y axis, and the fifth and sixth specify the limits for the z axis.
Without any arguments,
axisturns autoscaling on.
With one output argument,
x=axisreturns the current axes (this is not yet implemented for automatic axes).
The vector argument specifying limits is optional, and additional string arguments may be used to specify various axis properties. For example,axis ([1, 2, 3, 4], "square");
forces a square aspect ratio, andaxis ("labely", "tic");
turns tic marks on for all axes and tic mark labels on for the y-axis only.
The following options control the aspect ratio of the axes.
- Force a square aspect ratio.
- Force x distance to equal y-distance.
- Restore the balance.
The following options control the way axis limits are interpreted.
- Set the specified axes to have nice limits around the data or all if no axes are specified.
- Fix the current axes limits.
- Fix axes to the limits of the data (not implemented).
"image"is equivalent to
The following options affect the appearance of tic marks.
Note, if there are no tic marks for an axis, there can be no labels.
- Turn tic marks and labels on for all axes.
- Turn tic marks off for all axes.
- Turn tic marks on for all axes, or turn them on for the specified axes and off for the remainder.
- Turn tic labels on for all axes, or turn them on for the specified axes and off for the remainder.
- Turn tic labels off for all axes.
The following options affect the direction of increasing values on the axes.
- Reverse y-axis, so lower values are nearer the top.
- Restore y-axis, so higher values are nearer the top.