2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3368
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} plot (@var{args}) |
|
22 ## This function produces two-dimensional plots. Many different |
|
23 ## combinations of arguments are possible. The simplest form is |
3426
|
24 ## |
3368
|
25 ## @example |
|
26 ## plot (@var{y}) |
|
27 ## @end example |
3426
|
28 ## |
3368
|
29 ## @noindent |
|
30 ## where the argument is taken as the set of @var{y} coordinates and the |
|
31 ## @var{x} coordinates are taken to be the indices of the elements, |
|
32 ## starting with 1. |
3426
|
33 ## |
5798
|
34 ## To save a plot, in one of several image formats such as PostScript |
|
35 ## or PNG, use the @code{print} command. |
|
36 ## |
3368
|
37 ## If more than one argument is given, they are interpreted as |
3426
|
38 ## |
3368
|
39 ## @example |
|
40 ## plot (@var{x}, @var{y}, @var{fmt} ...) |
|
41 ## @end example |
3426
|
42 ## |
3368
|
43 ## @noindent |
|
44 ## where @var{y} and @var{fmt} are optional, and any number of argument |
|
45 ## sets may appear. The @var{x} and @var{y} values are |
|
46 ## interpreted as follows: |
3426
|
47 ## |
3368
|
48 ## @itemize @bullet |
|
49 ## @item |
|
50 ## If a single data argument is supplied, it is taken as the set of @var{y} |
|
51 ## coordinates and the @var{x} coordinates are taken to be the indices of |
|
52 ## the elements, starting with 1. |
3426
|
53 ## |
3368
|
54 ## @item |
6177
|
55 ## If the @var{x} is a vector and @var{y} is a matrix, the |
|
56 ## the columns (or rows) of @var{y} are plotted versus @var{x}. |
2311
|
57 ## (using whichever combination matches, with columns tried first.) |
3426
|
58 ## |
3368
|
59 ## @item |
6177
|
60 ## If the @var{x} is a matrix and @var{y} is a vector, |
|
61 ## @var{y} is plotted versus the columns (or rows) of @var{x}. |
2311
|
62 ## (using whichever combination matches, with columns tried first.) |
3426
|
63 ## |
3368
|
64 ## @item |
|
65 ## If both arguments are vectors, the elements of @var{y} are plotted versus |
|
66 ## the elements of @var{x}. |
3426
|
67 ## |
3368
|
68 ## @item |
|
69 ## If both arguments are matrices, the columns of @var{y} are plotted |
|
70 ## versus the columns of @var{x}. In this case, both matrices must have |
|
71 ## the same number of rows and columns and no attempt is made to transpose |
|
72 ## the arguments to make the number of rows match. |
3426
|
73 ## |
2311
|
74 ## If both arguments are scalars, a single point is plotted. |
3368
|
75 ## @end itemize |
3426
|
76 ## |
3368
|
77 ## If the @var{fmt} argument is supplied, it is interpreted as |
|
78 ## follows. If @var{fmt} is missing, the default gnuplot line style |
|
79 ## is assumed. |
3426
|
80 ## |
3368
|
81 ## @table @samp |
|
82 ## @item - |
|
83 ## Set lines plot style (default). |
3426
|
84 ## |
3368
|
85 ## @item . |
|
86 ## Set dots plot style. |
3426
|
87 ## |
3368
|
88 ## @item @@ |
|
89 ## Set points plot style. |
3426
|
90 ## |
3368
|
91 ## @item -@@ |
|
92 ## Set linespoints plot style. |
3426
|
93 ## |
3368
|
94 ## @item ^ |
|
95 ## Set impulses plot style. |
3426
|
96 ## |
3368
|
97 ## @item L |
|
98 ## Set steps plot style. |
3426
|
99 ## |
3368
|
100 ## @item @var{n} |
|
101 ## Interpreted as the plot color if @var{n} is an integer in the range 1 to |
|
102 ## 6. |
3426
|
103 ## |
3368
|
104 ## @item @var{nm} |
|
105 ## If @var{nm} is a two digit integer and @var{m} is an integer in the |
|
106 ## range 1 to 6, @var{m} is interpreted as the point style. This is only |
|
107 ## valid in combination with the @code{@@} or @code{-@@} specifiers. |
3426
|
108 ## |
3368
|
109 ## @item @var{c} |
6177
|
110 ## If @var{c} is one of @code{"k"} (black), @code{"r"} (red), @code{"g"} |
|
111 ## (green), @code{"b"} (blue), @code{"m"} (magenta), @code{"c"} (cyan), |
|
112 ## or @code{"w"} (white), it is interpreted as the line plot color. |
3426
|
113 ## |
3717
|
114 ## @item ";title;" |
|
115 ## Here @code{"title"} is the label for the key. |
|
116 ## |
3368
|
117 ## @item + |
|
118 ## @itemx * |
|
119 ## @itemx o |
|
120 ## @itemx x |
|
121 ## Used in combination with the points or linespoints styles, set the point |
|
122 ## style. |
|
123 ## @end table |
3426
|
124 ## |
3368
|
125 ## The color line styles have the following meanings on terminals that |
|
126 ## support color. |
3426
|
127 ## |
3368
|
128 ## @example |
|
129 ## Number Gnuplot colors (lines)points style |
|
130 ## 1 red * |
|
131 ## 2 green + |
|
132 ## 3 blue o |
|
133 ## 4 magenta x |
|
134 ## 5 cyan house |
|
135 ## 6 brown there exists |
|
136 ## @end example |
3426
|
137 ## |
3683
|
138 ## The @var{fmt} argument can also be used to assign key titles. |
|
139 ## To do so, include the desired title between semi-colons after the |
|
140 ## formatting sequence described above, e.g. "+3;Key Title;" |
|
141 ## Note that the last semi-colon is required and will generate an error if |
|
142 ## it is left out. |
|
143 ## |
3368
|
144 ## Here are some plot examples: |
3426
|
145 ## |
3368
|
146 ## @example |
|
147 ## plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+") |
|
148 ## @end example |
3426
|
149 ## |
3368
|
150 ## This command will plot @code{y} with points of type 2 (displayed as |
|
151 ## @samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of |
|
152 ## color 4 (magenta) and @code{y4} with points displayed as @samp{+}. |
3426
|
153 ## |
3368
|
154 ## @example |
|
155 ## plot (b, "*") |
|
156 ## @end example |
3426
|
157 ## |
3368
|
158 ## This command will plot the data in the variable @code{b} will be plotted |
|
159 ## with points displayed as @samp{*}. |
3683
|
160 ## |
|
161 ## @example |
|
162 ## t = 0:0.1:6.3; |
|
163 ## plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"); |
|
164 ## @end example |
|
165 ## |
|
166 ## This will plot the cosine and sine functions and label them accordingly |
|
167 ## in the key. |
5642
|
168 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ |
5798
|
169 ## bar, stairs, errorbar, replot, xlabel, ylabel, title, print} |
3368
|
170 ## @end deftypefn |
4
|
171 |
2314
|
172 ## Author: jwe |
|
173 |
6302
|
174 function retval = plot (varargin) |
4
|
175 |
6257
|
176 newplot (); |
3063
|
177 |
6302
|
178 tmp = __plt__ ("plot", gca (), varargin{:}); |
|
179 |
|
180 if (nargout > 0) |
|
181 retval = tmp; |
|
182 endif |
4
|
183 |
|
184 endfunction |