5837
|
1 ## Copyright (C) 1996 John W. Eaton |
|
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 |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} plot (@var{args}) |
|
22 ## |
|
23 ## This function produces three-dimensional plots. Many different |
|
24 ## combinations of arguments are possible. The simplest form is |
|
25 ## |
|
26 ## @example |
|
27 ## plot3 (@var{x}, @var{y}, @var{z}) |
|
28 ## @end example |
|
29 ## |
|
30 ## @noindent |
|
31 ## where the arguments are taken to be the vertices of the points to be |
|
32 ## plotted in three dimensions. If all arguments are vectors of the same |
|
33 ## length, then a single continuous line is drawn. If all arguments are |
|
34 ## matrices, then each column of the matrices is treated as a seperate |
|
35 ## line. No attempt is made to transpose the arguments to make the |
|
36 ## number of rows match. |
|
37 ## |
|
38 ## To save a plot, in one of several image formats such as PostScript |
|
39 ## or PNG, use the @code{print} command. |
|
40 ## |
|
41 ## An optional format argument can be given as |
|
42 ## |
|
43 ## @example |
|
44 ## plot3 (@var{x}, @var{y}, @var{y}, @var{fmt}) |
|
45 ## @end example |
|
46 ## |
|
47 ## If the @var{fmt} argument is supplied, it is interpreted as |
|
48 ## follows. If @var{fmt} is missing, the default gnuplot line style |
|
49 ## is assumed. |
|
50 ## |
|
51 ## @table @samp |
|
52 ## @item - |
|
53 ## Set lines plot style (default). |
|
54 ## |
|
55 ## @item . |
|
56 ## Set dots plot style. |
|
57 ## |
|
58 ## @item @@ |
|
59 ## Set points plot style. |
|
60 ## |
|
61 ## @item -@@ |
|
62 ## Set linespoints plot style. |
|
63 ## |
|
64 ## @item ^ |
|
65 ## Set impulses plot style. |
|
66 ## |
|
67 ## @item L |
|
68 ## Set steps plot style. |
|
69 ## |
|
70 ## @item @var{n} |
|
71 ## Interpreted as the plot color if @var{n} is an integer in the range 1 to |
|
72 ## 6. |
|
73 ## |
|
74 ## @item @var{nm} |
|
75 ## If @var{nm} is a two digit integer and @var{m} is an integer in the |
|
76 ## range 1 to 6, @var{m} is interpreted as the point style. This is only |
|
77 ## valid in combination with the @code{@@} or @code{-@@} specifiers. |
|
78 ## |
|
79 ## @item @var{c} |
|
80 ## If @var{c} is one of @code{"k"}, @code{"r"}, @code{"g"}, @code{"b"}, |
|
81 ## @code{"m"}, @code{"c"}, or @code{"w"}, it is interpreted as the plot |
|
82 ## color (black, red, green, blue, magenta, cyan, or white). |
|
83 ## |
|
84 ## @item ";title;" |
|
85 ## Here @code{"title"} is the label for the key. |
|
86 ## |
|
87 ## @item + |
|
88 ## @itemx * |
|
89 ## @itemx o |
|
90 ## @itemx x |
|
91 ## Used in combination with the points or linespoints styles, set the point |
|
92 ## style. |
|
93 ## @end table |
|
94 ## |
|
95 ## The color line styles have the following meanings on terminals that |
|
96 ## support color. |
|
97 ## |
|
98 ## @example |
|
99 ## Number Gnuplot colors (lines)points style |
|
100 ## 1 red * |
|
101 ## 2 green + |
|
102 ## 3 blue o |
|
103 ## 4 magenta x |
|
104 ## 5 cyan house |
|
105 ## 6 brown there exists |
|
106 ## @end example |
|
107 ## |
|
108 ## The @var{fmt} argument can also be used to assign key titles. |
|
109 ## To do so, include the desired title between semi-colons after the |
|
110 ## formatting sequence described above, e.g. "+3;Key Title;" |
|
111 ## Note that the last semi-colon is required and will generate an error if |
|
112 ## it is left out. |
|
113 ## |
|
114 ## Arguments can also be given in groups of three as |
|
115 ## |
|
116 ## @example |
|
117 ## plot3 (@var{x1}, @var{y1}, @var{y1}, @var{x2}, @var{y2}, @var{y2}, @dots{}) |
|
118 ## @end example |
|
119 ## |
|
120 ## @noindent |
|
121 ## where each set of three arguments are treated as seperate lines or |
|
122 ## sets of lines in three dimensions. |
|
123 ## |
|
124 ## An example of the use of plot3 is |
|
125 ## |
|
126 ## @example |
|
127 ## @group |
|
128 ## z = [0:0.05:5]; |
|
129 ## plot3(cos(2*pi*z), sin(2*pi*z), z, ";helix;"); |
|
130 ## @end group |
|
131 ## @end example |
|
132 ## |
|
133 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ |
|
134 ## bar, stairs, errorbar, replot, xlabel, ylabel, title, print} |
|
135 ## @end deftypefn |
|
136 |
|
137 ## Author: Paul Kienzle |
|
138 ## (modified from __plt__.m) |
|
139 |
|
140 function plot3(varargin) |
|
141 |
|
142 hold_state = ishold (); |
|
143 |
|
144 unwind_protect |
|
145 |
|
146 x_set = 0; |
|
147 y_set = 0; |
|
148 z_set = 0; |
|
149 |
|
150 ## Gather arguments, decode format, and plot lines. |
|
151 for arg = 1:length(varargin) |
|
152 new = varargin{arg}; |
|
153 |
|
154 if (ischar (new)) |
|
155 if (! z_set) |
|
156 error ("plot3: needs x, y, z"); |
|
157 endif |
|
158 fmt = __pltopt__ ("plot3", new); |
|
159 __plt3__(x, y, z, fmt); |
|
160 hold on; |
|
161 x_set = 0; |
|
162 y_set = 0; |
|
163 z_set = 0; |
|
164 elseif (!x_set) |
|
165 x = new; |
|
166 x_set = 1; |
|
167 elseif (!y_set) |
|
168 y = new; |
|
169 y_set = 1; |
|
170 elseif (!z_set) |
|
171 z = new; |
|
172 z_set = 1; |
|
173 else |
|
174 __plt3__ (x, y, z, ""); |
|
175 hold on; |
|
176 x = new; |
|
177 y_set = 0; |
|
178 z_set = 0; |
|
179 endif |
|
180 |
|
181 endfor |
|
182 |
|
183 ## Handle last plot. |
|
184 |
|
185 if (z_set) |
|
186 __plt3__ (x, y, z, ""); |
|
187 elseif (x_set) |
|
188 error ("plot3: needs x, y, z"); |
|
189 endif |
|
190 |
|
191 unwind_protect_cleanup |
|
192 |
|
193 if (! hold_state) |
|
194 hold off; |
|
195 endif |
|
196 |
|
197 end_unwind_protect |
|
198 |
|
199 endfunction |