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 ## |
3368
|
34 ## If more than one argument is given, they are interpreted as |
3426
|
35 ## |
3368
|
36 ## @example |
|
37 ## plot (@var{x}, @var{y}, @var{fmt} ...) |
|
38 ## @end example |
3426
|
39 ## |
3368
|
40 ## @noindent |
|
41 ## where @var{y} and @var{fmt} are optional, and any number of argument |
|
42 ## sets may appear. The @var{x} and @var{y} values are |
|
43 ## interpreted as follows: |
3426
|
44 ## |
3368
|
45 ## @itemize @bullet |
|
46 ## @item |
|
47 ## If a single data argument is supplied, it is taken as the set of @var{y} |
|
48 ## coordinates and the @var{x} coordinates are taken to be the indices of |
|
49 ## the elements, starting with 1. |
3426
|
50 ## |
3368
|
51 ## @item |
2311
|
52 ## If the first argument is a vector and the second is a matrix, the |
|
53 ## the vector is plotted versus the columns (or rows) of the matrix. |
|
54 ## (using whichever combination matches, with columns tried first.) |
3426
|
55 ## |
3368
|
56 ## @item |
2311
|
57 ## If the first argument is a matrix and the second is a vector, the |
|
58 ## the columns (or rows) of the matrix are plotted versus the vector. |
|
59 ## (using whichever combination matches, with columns tried first.) |
3426
|
60 ## |
3368
|
61 ## @item |
|
62 ## If both arguments are vectors, the elements of @var{y} are plotted versus |
|
63 ## the elements of @var{x}. |
3426
|
64 ## |
3368
|
65 ## @item |
|
66 ## If both arguments are matrices, the columns of @var{y} are plotted |
|
67 ## versus the columns of @var{x}. In this case, both matrices must have |
|
68 ## the same number of rows and columns and no attempt is made to transpose |
|
69 ## the arguments to make the number of rows match. |
3426
|
70 ## |
2311
|
71 ## If both arguments are scalars, a single point is plotted. |
3368
|
72 ## @end itemize |
3426
|
73 ## |
3368
|
74 ## If the @var{fmt} argument is supplied, it is interpreted as |
|
75 ## follows. If @var{fmt} is missing, the default gnuplot line style |
|
76 ## is assumed. |
3426
|
77 ## |
3368
|
78 ## @table @samp |
|
79 ## @item - |
|
80 ## Set lines plot style (default). |
3426
|
81 ## |
3368
|
82 ## @item . |
|
83 ## Set dots plot style. |
3426
|
84 ## |
3368
|
85 ## @item @@ |
|
86 ## Set points plot style. |
3426
|
87 ## |
3368
|
88 ## @item -@@ |
|
89 ## Set linespoints plot style. |
3426
|
90 ## |
3368
|
91 ## @item ^ |
|
92 ## Set impulses plot style. |
3426
|
93 ## |
3368
|
94 ## @item L |
|
95 ## Set steps plot style. |
3426
|
96 ## |
3368
|
97 ## @item @var{n} |
|
98 ## Interpreted as the plot color if @var{n} is an integer in the range 1 to |
|
99 ## 6. |
3426
|
100 ## |
3368
|
101 ## @item @var{nm} |
|
102 ## If @var{nm} is a two digit integer and @var{m} is an integer in the |
|
103 ## range 1 to 6, @var{m} is interpreted as the point style. This is only |
|
104 ## valid in combination with the @code{@@} or @code{-@@} specifiers. |
3426
|
105 ## |
3368
|
106 ## @item @var{c} |
5462
|
107 ## If @var{c} is one of @code{"k"}, @code{"r"}, @code{"g"}, @code{"b"}, |
|
108 ## @code{"m"}, @code{"c"}, or @code{"w"}, it is interpreted as the plot |
|
109 ## color (black, red, green, blue, magenta, cyan, or white). |
3426
|
110 ## |
3717
|
111 ## @item ";title;" |
|
112 ## Here @code{"title"} is the label for the key. |
|
113 ## |
3368
|
114 ## @item + |
|
115 ## @itemx * |
|
116 ## @itemx o |
|
117 ## @itemx x |
|
118 ## Used in combination with the points or linespoints styles, set the point |
|
119 ## style. |
|
120 ## @end table |
3426
|
121 ## |
3368
|
122 ## The color line styles have the following meanings on terminals that |
|
123 ## support color. |
3426
|
124 ## |
3368
|
125 ## @example |
|
126 ## Number Gnuplot colors (lines)points style |
|
127 ## 1 red * |
|
128 ## 2 green + |
|
129 ## 3 blue o |
|
130 ## 4 magenta x |
|
131 ## 5 cyan house |
|
132 ## 6 brown there exists |
|
133 ## @end example |
3426
|
134 ## |
3683
|
135 ## The @var{fmt} argument can also be used to assign key titles. |
|
136 ## To do so, include the desired title between semi-colons after the |
|
137 ## formatting sequence described above, e.g. "+3;Key Title;" |
|
138 ## Note that the last semi-colon is required and will generate an error if |
|
139 ## it is left out. |
|
140 ## |
3368
|
141 ## Here are some plot examples: |
3426
|
142 ## |
3368
|
143 ## @example |
|
144 ## plot (x, y, "@@12", x, y2, x, y3, "4", x, y4, "+") |
|
145 ## @end example |
3426
|
146 ## |
3368
|
147 ## This command will plot @code{y} with points of type 2 (displayed as |
|
148 ## @samp{+}) and color 1 (red), @code{y2} with lines, @code{y3} with lines of |
|
149 ## color 4 (magenta) and @code{y4} with points displayed as @samp{+}. |
3426
|
150 ## |
3368
|
151 ## @example |
|
152 ## plot (b, "*") |
|
153 ## @end example |
3426
|
154 ## |
3368
|
155 ## This command will plot the data in the variable @code{b} will be plotted |
|
156 ## with points displayed as @samp{*}. |
3683
|
157 ## |
|
158 ## @example |
|
159 ## t = 0:0.1:6.3; |
|
160 ## plot (t, cos(t), "-;cos(t);", t, sin(t), "+3;sin(t);"); |
|
161 ## @end example |
|
162 ## |
|
163 ## This will plot the cosine and sine functions and label them accordingly |
|
164 ## in the key. |
3368
|
165 ## @end deftypefn |
5053
|
166 ## |
3407
|
167 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ |
5214
|
168 ## bar, stairs, errorbar, replot, xlabel, ylabel, and title} |
4
|
169 |
2314
|
170 ## Author: jwe |
|
171 |
3979
|
172 function plot (varargin) |
4
|
173 |
3063
|
174 ## XXX FIXME XXX -- these plot states should really just be set |
|
175 ## temporarily, probably inside an unwind_protect block, but there is |
|
176 ## no way to determine their current values. |
|
177 |
5252
|
178 __gnuplot_raw__ ("set nologscale;\n"); |
|
179 __gnuplot_raw__ ("set nopolar;\n"); |
4
|
180 |
3979
|
181 __plt__ ("plot", varargin{:}); |
4
|
182 |
|
183 endfunction |