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 |
6459
|
40 ## plot (@var{x}, @var{y}, @var{fmt}, @dots{}) |
3368
|
41 ## @end example |
3426
|
42 ## |
3368
|
43 ## @noindent |
6459
|
44 ## or as |
|
45 ## |
|
46 ## @example |
|
47 ## plot (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) |
|
48 ## @end example |
|
49 ## |
|
50 ## @noindent |
|
51 ## where @var{y}, @var{fmt}, @var{property} and @var{value} are optional, |
|
52 ## and any number of argument sets may appear. The @var{x} and @var{y} |
|
53 ## values are interpreted as follows: |
3426
|
54 ## |
3368
|
55 ## @itemize @bullet |
|
56 ## @item |
|
57 ## If a single data argument is supplied, it is taken as the set of @var{y} |
|
58 ## coordinates and the @var{x} coordinates are taken to be the indices of |
|
59 ## the elements, starting with 1. |
3426
|
60 ## |
3368
|
61 ## @item |
6672
|
62 ## If the @var{x} is a vector and @var{y} is a matrix, then |
6177
|
63 ## the columns (or rows) of @var{y} are plotted versus @var{x}. |
2311
|
64 ## (using whichever combination matches, with columns tried first.) |
3426
|
65 ## |
3368
|
66 ## @item |
6177
|
67 ## If the @var{x} is a matrix and @var{y} is a vector, |
|
68 ## @var{y} is plotted versus the columns (or rows) of @var{x}. |
2311
|
69 ## (using whichever combination matches, with columns tried first.) |
3426
|
70 ## |
3368
|
71 ## @item |
|
72 ## If both arguments are vectors, the elements of @var{y} are plotted versus |
|
73 ## the elements of @var{x}. |
3426
|
74 ## |
3368
|
75 ## @item |
|
76 ## If both arguments are matrices, the columns of @var{y} are plotted |
|
77 ## versus the columns of @var{x}. In this case, both matrices must have |
|
78 ## the same number of rows and columns and no attempt is made to transpose |
|
79 ## the arguments to make the number of rows match. |
3426
|
80 ## |
2311
|
81 ## If both arguments are scalars, a single point is plotted. |
3368
|
82 ## @end itemize |
3426
|
83 ## |
3368
|
84 ## If the @var{fmt} argument is supplied, it is interpreted as |
|
85 ## follows. If @var{fmt} is missing, the default gnuplot line style |
|
86 ## is assumed. |
3426
|
87 ## |
3368
|
88 ## @table @samp |
|
89 ## @item - |
|
90 ## Set lines plot style (default). |
3426
|
91 ## |
3368
|
92 ## @item . |
|
93 ## Set dots plot style. |
3426
|
94 ## |
3368
|
95 ## @item ^ |
|
96 ## Set impulses plot style. |
3426
|
97 ## |
3368
|
98 ## @item L |
|
99 ## Set steps plot style. |
3426
|
100 ## |
3368
|
101 ## @item @var{n} |
|
102 ## Interpreted as the plot color if @var{n} is an integer in the range 1 to |
|
103 ## 6. |
3426
|
104 ## |
3368
|
105 ## @item @var{nm} |
|
106 ## If @var{nm} is a two digit integer and @var{m} is an integer in the |
|
107 ## range 1 to 6, @var{m} is interpreted as the point style. This is only |
|
108 ## valid in combination with the @code{@@} or @code{-@@} specifiers. |
3426
|
109 ## |
3368
|
110 ## @item @var{c} |
6177
|
111 ## If @var{c} is one of @code{"k"} (black), @code{"r"} (red), @code{"g"} |
|
112 ## (green), @code{"b"} (blue), @code{"m"} (magenta), @code{"c"} (cyan), |
|
113 ## or @code{"w"} (white), it is interpreted as the line plot color. |
3426
|
114 ## |
3717
|
115 ## @item ";title;" |
|
116 ## Here @code{"title"} is the label for the key. |
|
117 ## |
3368
|
118 ## @item + |
|
119 ## @itemx * |
|
120 ## @itemx o |
|
121 ## @itemx x |
|
122 ## Used in combination with the points or linespoints styles, set the point |
|
123 ## style. |
|
124 ## @end table |
3426
|
125 ## |
3368
|
126 ## The color line styles have the following meanings on terminals that |
|
127 ## support color. |
3426
|
128 ## |
3368
|
129 ## @example |
|
130 ## Number Gnuplot colors (lines)points style |
|
131 ## 1 red * |
|
132 ## 2 green + |
|
133 ## 3 blue o |
|
134 ## 4 magenta x |
|
135 ## 5 cyan house |
|
136 ## 6 brown there exists |
|
137 ## @end example |
3426
|
138 ## |
3683
|
139 ## The @var{fmt} argument can also be used to assign key titles. |
|
140 ## To do so, include the desired title between semi-colons after the |
|
141 ## formatting sequence described above, e.g. "+3;Key Title;" |
|
142 ## Note that the last semi-colon is required and will generate an error if |
|
143 ## it is left out. |
|
144 ## |
6459
|
145 ## If a @var{property} is given it must be followed by @var{value}. The |
|
146 ## property value pairs are applied to the lines drawn by @code{plot}. |
|
147 ## |
3368
|
148 ## Here are some plot examples: |
3426
|
149 ## |
3368
|
150 ## @example |
|
151 ## plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+") |
|
152 ## @end example |
3426
|
153 ## |
3368
|
154 ## This command will plot @code{y} with points of type 2 (displayed as |
|
155 ## @samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of |
|
156 ## color 4 (magenta) and @code{y4} with points displayed as @samp{+}. |
3426
|
157 ## |
3368
|
158 ## @example |
6459
|
159 ## plot (b, "*", "markersize", 3) |
3368
|
160 ## @end example |
3426
|
161 ## |
6672
|
162 ## This command will plot the data in the variable @code{b}, |
6459
|
163 ## with points displayed as @samp{*} with a marker size of 3. |
3683
|
164 ## |
|
165 ## @example |
|
166 ## t = 0:0.1:6.3; |
|
167 ## plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"); |
|
168 ## @end example |
|
169 ## |
|
170 ## This will plot the cosine and sine functions and label them accordingly |
|
171 ## in the key. |
6820
|
172 ## |
|
173 ## If the first argument is an axis handle, then plot into these axes, |
|
174 ## rather than the current axis handle returned by @code{gca}. |
5642
|
175 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ |
6448
|
176 ## bar, stairs, errorbar, xlabel, ylabel, title, print} |
3368
|
177 ## @end deftypefn |
4
|
178 |
2314
|
179 ## Author: jwe |
|
180 |
6302
|
181 function retval = plot (varargin) |
4
|
182 |
6820
|
183 if (isscalar (varargin{1}) && ishandle (varargin{1})) |
|
184 h = varargin {1}; |
6828
|
185 if (! strcmp (get (h, "type"), "axes")) |
6820
|
186 error ("plot: expecting first argument to be an axes object"); |
|
187 endif |
|
188 oldh = gca (); |
|
189 unwind_protect |
|
190 axes (h); |
|
191 newplot (); |
|
192 tmp = __plt__ ("plot", h, varargin{2:end}); |
|
193 unwind_protect_cleanup |
|
194 axes (oldh); |
|
195 end_unwind_protect |
|
196 else |
|
197 newplot (); |
|
198 tmp = __plt__ ("plot", gca (), varargin{:}); |
|
199 endif |
6302
|
200 |
|
201 if (nargout > 0) |
|
202 retval = tmp; |
|
203 endif |
4
|
204 |
|
205 endfunction |