Mercurial > hg > octave-lyh
annotate scripts/plot/plot3.m @ 14363:f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
* wavread.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m,
asec.m, asecd.m, asech.m, asind.m, atand.m, cosd.m, cot.m, cotd.m, coth.m,
csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m,
accumdim.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m,
celldisp.m, chop.m, circshift.m, colon.m, common_size.m, cplxpair.m,
cumtrapz.m, curl.m, dblquad.m, deal.m, divergence.m, flipdim.m, fliplr.m,
flipud.m, genvarname.m, gradient.m, idivide.m, int2str.m, interp1.m,
interp1q.m, interp2.m, interp3.m, interpft.m, interpn.m, isa.m, isdir.m,
isequal.m, isequalwithequalnans.m, issquare.m, logspace.m, nargchk.m,
narginchk.m, nargoutchk.m, nextpow2.m, nthargout.m, num2str.m, pol2cart.m,
polyarea.m, postpad.m, prepad.m, profile.m, profshow.m, quadgk.m, quadv.m,
randi.m, rat.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sph2cart.m,
structfun.m, trapz.m, triplequad.m, convhull.m, dsearch.m, dsearchn.m,
griddata3.m, griddatan.m, rectint.m, tsearchn.m, __makeinfo__.m, doc.m,
get_first_help_sentence.m, help.m, type.m, unimplemented.m, which.m, imread.m,
imwrite.m, dlmwrite.m, fileread.m, is_valid_file_id.m, strread.m, textread.m,
textscan.m, commutation_matrix.m, cond.m, condest.m, cross.m,
duplication_matrix.m, expm.m, housh.m, isdefinite.m, ishermitian.m,
issymmetric.m, logm.m, normest.m, null.m, onenormest.m, orth.m, planerot.m,
qzhess.m, rank.m, rref.m, trace.m, vech.m, ans.m, bincoeff.m, bug_report.m,
bzip2.m, comma.m, compare_versions.m, computer.m, edit.m, fileparts.m,
fullfile.m, getfield.m, gzip.m, info.m, inputname.m, isappdata.m, isdeployed.m,
ismac.m, ispc.m, isunix.m, list_primes.m, ls.m, mexext.m, namelengthmax.m,
news.m, orderfields.m, paren.m, recycle.m, rmappdata.m, semicolon.m,
setappdata.m, setfield.m, substruct.m, symvar.m, ver.m, version.m,
warning_ids.m, xor.m, fminbnd.m, fsolve.m, fzero.m, lsqnonneg.m, optimset.m,
pqpnonneg.m, sqp.m, matlabroot.m, __gnuplot_drawnow__.m,
__plt_get_axis_arg__.m, ancestor.m, cla.m, clf.m, close.m, colorbar.m,
colstyle.m, comet3.m, contourc.m, figure.m, gca.m, gcbf.m, gcbo.m, gcf.m,
ginput.m, graphics_toolkit.m, gtext.m, hggroup.m, hist.m, hold.m, isfigure.m,
ishghandle.m, ishold.m, isocolors.m, isonormals.m, isosurface.m, isprop.m,
legend.m, line.m, loglog.m, loglogerr.m, meshgrid.m, ndgrid.m, newplot.m,
orient.m, patch.m, plot3.m, plotyy.m, __print_parse_opts__.m, quiver3.m,
refreshdata.m, ribbon.m, semilogx.m, semilogxerr.m, semilogy.m, stem.m,
stem3.m, subplot.m, title.m, uigetfile.m, view.m, whitebg.m, compan.m, conv.m,
deconv.m, mkpp.m, mpoles.m, pchip.m, poly.m, polyaffine.m, polyder.m,
polyfit.m, polygcd.m, polyint.m, polyout.m, polyval.m, polyvalm.m, ppder.m,
ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, intersect.m,
ismember.m, powerset.m, setdiff.m, setxor.m, union.m, unique.m,
autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, fftconv.m, fftfilt.m,
fftshift.m, freqz.m, hamming.m, hanning.m, ifftshift.m, sinc.m, sinetone.m,
sinewave.m, unwrap.m, bicg.m, bicgstab.m, gmres.m, gplot.m, nonzeros.m, pcg.m,
pcr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m,
sprand.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, bessel.m,
beta.m, betaln.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m,
nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m,
realsqrt.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, rosser.m,
vander.m, __finish__.m, center.m, cloglog.m, corr.m, cov.m, gls.m, histc.m,
iqr.m, kendall.m, kurtosis.m, logit.m, mahalanobis.m, mean.m, meansq.m,
median.m, mode.m, moment.m, ols.m, ppplot.m, prctile.m, probit.m, quantile.m,
range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m,
statistics.m, std.m, table.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m,
betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m,
cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m,
chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m,
empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m,
expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m,
gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m,
hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m,
laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m,
logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m,
lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m,
norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m,
poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m,
tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m,
unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m,
wblrnd.m, kolmogorov_smirnov_test.m, kruskal_wallis_test.m, base2dec.m,
bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m,
findstr.m, hex2dec.m, index.m, isletter.m, mat2str.m, rindex.m, str2num.m,
strcat.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m,
substr.m, validatestring.m, demo.m, example.m, fail.m, speed.m, addtodate.m,
asctime.m, clock.m, ctime.m, date.m, datenum.m, datetick.m, datevec.m,
eomday.m, etime.m, is_leap_year.m, now.m:
Use Octave coding conventions in all m-file %!test blocks
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 13 Feb 2012 07:29:44 -0800 |
parents | ce2b59a6d0e5 |
children | 460a3c6d8bf1 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 1996-2012 John W. Eaton |
5837 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5837 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5837 | 18 |
19 ## -*- texinfo -*- | |
5910 | 20 ## @deftypefn {Function File} {} plot3 (@var{args}) |
6895 | 21 ## Produce three-dimensional plots. Many different combinations of |
22 ## arguments are possible. The simplest form is | |
5837 | 23 ## |
24 ## @example | |
25 ## plot3 (@var{x}, @var{y}, @var{z}) | |
26 ## @end example | |
27 ## | |
28 ## @noindent | |
6895 | 29 ## in which the arguments are taken to be the vertices of the points to |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
30 ## be plotted in three dimensions. If all arguments are vectors of the |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
31 ## same length, then a single continuous line is drawn. If all arguments |
6895 | 32 ## are matrices, then each column of the matrices is treated as a |
7001 | 33 ## separate line. No attempt is made to transpose the arguments to make |
6895 | 34 ## the number of rows match. |
5837 | 35 ## |
6895 | 36 ## If only two arguments are given, as |
5910 | 37 ## |
38 ## @example | |
39 ## plot3 (@var{x}, @var{c}) | |
40 ## @end example | |
41 ## | |
6895 | 42 ## @noindent |
43 ## the real and imaginary parts of the second argument are used | |
44 ## as the @var{y} and @var{z} coordinates, respectively. | |
5910 | 45 ## |
46 ## If only one argument is given, as | |
47 ## | |
48 ## @example | |
49 ## plot3 (@var{c}) | |
50 ## @end example | |
51 ## | |
6895 | 52 ## @noindent |
5910 | 53 ## the real and imaginary parts of the argument are used as the @var{y} |
54 ## and @var{z} values, and they are plotted versus their index. | |
55 ## | |
6895 | 56 ## Arguments may also be given in groups of three as |
5837 | 57 ## |
58 ## @example | |
6146 | 59 ## plot3 (@var{x1}, @var{y1}, @var{z1}, @var{x2}, @var{y2}, @var{z2}, @dots{}) |
5837 | 60 ## @end example |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
61 ## |
5837 | 62 ## @noindent |
7001 | 63 ## in which each set of three arguments is treated as a separate line or |
5910 | 64 ## set of lines in three dimensions. |
65 ## | |
6895 | 66 ## To plot multiple one- or two-argument groups, separate each group |
67 ## with an empty format string, as | |
5910 | 68 ## |
69 ## @example | |
6895 | 70 ## plot3 (@var{x1}, @var{c1}, "", @var{c2}, "", @dots{}) |
5910 | 71 ## @end example |
5837 | 72 ## |
6895 | 73 ## An example of the use of @code{plot3} is |
5837 | 74 ## |
75 ## @example | |
76 ## @group | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
77 ## z = [0:0.05:5]; |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
78 ## plot3 (cos (2*pi*z), sin (2*pi*z), z, ";helix;"); |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
79 ## plot3 (z, exp (2i*pi*z), ";complex sinusoid;"); |
5837 | 80 ## @end group |
81 ## @end example | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8257
diff
changeset
|
82 ## @seealso{plot, xlabel, ylabel, zlabel, title, print} |
5837 | 83 ## @end deftypefn |
84 | |
85 ## Author: Paul Kienzle | |
86 ## (modified from __plt__.m) | |
87 | |
6302 | 88 function retval = plot3 (varargin) |
5837 | 89 |
6560 | 90 newplot (); |
91 | |
6257 | 92 x_set = 0; |
93 y_set = 0; | |
94 z_set = 0; | |
6459 | 95 property_set = 0; |
96 fmt_set = 0; | |
97 properties = {}; | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
98 tlgnd = {}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
99 hlgnd = []; |
6302 | 100 idx = 0; |
101 | |
6257 | 102 ## Gather arguments, decode format, and plot lines. |
6459 | 103 arg = 0; |
104 while (arg++ < nargin) | |
6257 | 105 new = varargin{arg}; |
6459 | 106 new_cell = varargin(arg); |
107 | |
108 if (property_set) | |
109 properties = [properties, new_cell]; | |
110 property_set = 0; | |
111 continue; | |
112 endif | |
6004 | 113 |
6257 | 114 if (ischar (new)) |
115 if (! z_set) | |
10549 | 116 if (! y_set) |
117 if (! x_set) | |
118 error ("plot3: needs x, [ y, [ z ] ]"); | |
119 else | |
120 z = imag (x); | |
121 y = real (x); | |
122 y_set = 1; | |
123 z_set = 1; | |
124 if (rows(x) > 1) | |
125 x = repmat ((1:rows(x))', 1, columns(x)); | |
126 else | |
127 x = 1:columns(x); | |
128 endif | |
129 endif | |
130 else | |
131 z = imag (y); | |
132 y = real (y); | |
133 z_set = 1; | |
134 endif | |
5837 | 135 endif |
6459 | 136 |
137 if (! fmt_set) | |
10549 | 138 [options, valid] = __pltopt__ ("plot3", new, false); |
139 if (! valid) | |
140 properties = [properties, new_cell]; | |
141 property_set = 1; | |
142 continue; | |
143 else | |
144 fmt_set = 1; | |
145 while (arg < nargin && ischar (varargin{arg+1})) | |
146 if (nargin - arg < 2) | |
147 error ("plot3: properties must appear followed by a value"); | |
148 endif | |
149 properties = [properties, varargin(arg+1:arg+2)]; | |
150 arg += 2; | |
151 endwhile | |
152 endif | |
6459 | 153 else |
10549 | 154 properties = [properties, new_cell]; |
155 property_set = 1; | |
156 continue; | |
6459 | 157 endif |
6004 | 158 |
159 if (isvector (x) && isvector (y)) | |
10549 | 160 if (isvector (z)) |
161 x = x(:); | |
162 y = y(:); | |
163 z = z(:); | |
164 elseif (length (x) == rows (z) && length (y) == columns (z)) | |
165 [x, y] = meshgrid (x, y); | |
166 else | |
167 error ("plot3: [length(x), length(y)] must match size(z)"); | |
168 endif | |
6004 | 169 endif |
170 | |
7292 | 171 if (! size_equal (x, y, z)) |
10549 | 172 error ("plot3: x, y, and z must have the same shape"); |
14184
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
173 elseif (ndims (x) > 2) |
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
174 error ("plot3: x, y, and z must not have more than two dimensions"); |
6004 | 175 endif |
176 | |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
177 for i = 1 : columns (x) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
178 linestyle = options.linestyle; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
179 marker = options.marker; |
10549 | 180 if (isempty (marker) && isempty (linestyle)) |
181 [linestyle, marker] = __next_line_style__ (); | |
182 endif | |
183 color = options.color; | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
184 if (isempty (color)) |
10549 | 185 color = __next_line_color__ (); |
186 endif | |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
187 |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
188 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), |
10549 | 189 "color", color, "linestyle", linestyle, |
190 "marker", marker, properties{:}); | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
191 key = options.key; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
192 if (! isempty (key)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
193 hlgnd = [hlgnd, tmp(idx)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
194 tlgnd = {tlgnd{:}, key}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
195 endif |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
196 endfor |
6004 | 197 |
6257 | 198 x_set = 0; |
199 y_set = 0; | |
200 z_set = 0; | |
6459 | 201 fmt_set = 0; |
202 properties = {}; | |
6257 | 203 elseif (! x_set) |
204 x = new; | |
205 x_set = 1; | |
206 elseif (! y_set) | |
207 y = new; | |
208 y_set = 1; | |
209 elseif (! z_set) | |
210 z = new; | |
211 z_set = 1; | |
212 else | |
213 if (isvector (x) && isvector (y)) | |
10549 | 214 if (isvector (z)) |
215 x = x(:); | |
216 y = y(:); | |
217 z = z(:); | |
218 elseif (length (x) == rows (z) && length (y) == columns (z)) | |
219 [x, y] = meshgrid (x, y); | |
220 else | |
221 error ("plot3: [length(x), length(y)] must match size(z)"); | |
222 endif | |
6257 | 223 endif |
224 | |
7292 | 225 if (! size_equal (x, y, z)) |
10549 | 226 error ("plot3: x, y, and z must have the same shape"); |
14184
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
227 elseif (ndims (x) > 2) |
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
228 error ("plot3: x, y, and z must not have more than two dimensions"); |
6257 | 229 endif |
230 | |
6459 | 231 options = __default_plot_options__ (); |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
232 for i = 1 : columns (x) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
233 linestyle = options.linestyle; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
234 marker = options.marker; |
10549 | 235 if (isempty (marker) && isempty (linestyle)) |
236 [linestyle, marker] = __next_line_style__ (); | |
237 endif | |
238 color = options.color; | |
239 if (isempty (color)) | |
240 color = __next_line_color__ (); | |
241 endif | |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
242 |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
243 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), |
10549 | 244 "color", color, "linestyle", linestyle, |
245 "marker", marker, properties{:}); | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
246 key = options.key; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
247 if (! isempty (key)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
248 hlgnd = [hlgnd, tmp(idx)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
249 tlgnd = {tlgnd{:}, key}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
250 endif |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
251 endfor |
6257 | 252 |
253 x = new; | |
254 y_set = 0; | |
255 z_set = 0; | |
6459 | 256 fmt_set = 0; |
257 properties = {}; | |
5837 | 258 endif |
6257 | 259 |
6459 | 260 endwhile |
261 | |
262 if (property_set) | |
263 error ("plot3: properties must appear followed by a value"); | |
264 endif | |
6257 | 265 |
266 ## Handle last plot. | |
267 | |
268 if (x_set) | |
269 if (y_set) | |
270 if (! z_set) | |
10549 | 271 z = imag (y); |
272 y = real (y); | |
273 z_set = 1; | |
6257 | 274 endif |
275 else | |
276 z = imag (x); | |
277 y = real (x); | |
278 y_set = 1; | |
279 z_set = 1; | |
280 if (rows (x) > 1) | |
10549 | 281 x = repmat ((1:rows (x))', 1, columns(x)); |
6257 | 282 else |
10549 | 283 x = 1:columns(x); |
6257 | 284 endif |
5837 | 285 endif |
6257 | 286 |
287 if (isvector (x) && isvector (y)) | |
288 if (isvector (z)) | |
10549 | 289 x = x(:); |
290 y = y(:); | |
291 z = z(:); | |
6257 | 292 elseif (length (x) == rows (z) && length (y) == columns (z)) |
10549 | 293 [x, y] = meshgrid (x, y); |
6257 | 294 else |
10549 | 295 error ("plot3: [length(x), length(y)] must match size(z)"); |
6257 | 296 endif |
297 endif | |
298 | |
7292 | 299 if (! size_equal (x, y, z)) |
6257 | 300 error ("plot3: x, y, and z must have the same shape"); |
14184
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
301 elseif (ndims (x) > 2) |
b33589ef9213
plot3.m: Throw error if the input data exceeds two dimensions.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
302 error ("plot3: x, y, and z must not have more than two dimensions"); |
6257 | 303 endif |
304 | |
6459 | 305 options = __default_plot_options__ (); |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
306 |
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
307 for i = 1 : columns (x) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
308 linestyle = options.linestyle; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
309 marker = options.marker; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
310 if (isempty (marker) && isempty (linestyle)) |
10549 | 311 [linestyle, marker] = __next_line_style__ (); |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
9385
diff
changeset
|
312 endif |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
313 color = options.color; |
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
314 if (isempty (color)) |
10549 | 315 color = __next_line_color__ (); |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
316 endif |
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
317 |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
318 tmp(++idx) = line (x(:, i), y(:, i), z(:, i), |
10549 | 319 "color", color, "linestyle", linestyle, |
320 "marker", marker, properties{:}); | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
321 key = options.key; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
322 if (! isempty (key)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
323 hlgnd = [hlgnd, tmp(idx)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
324 tlgnd = {tlgnd{:}, key}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
325 endif |
8078
4665276ff7f6
correctly plot matrices in plot3
David Bateman <dbateman@free.fr>
parents:
8075
diff
changeset
|
326 endfor |
6257 | 327 endif |
328 | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
329 if (!isempty (hlgnd)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
330 legend (gca(), hlgnd, tlgnd); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
331 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
332 |
6257 | 333 set (gca (), "view", [-37.5, 30]); |
5837 | 334 |
6302 | 335 if (nargout > 0 && idx > 0) |
336 retval = tmp; | |
337 endif | |
338 | |
5837 | 339 endfunction |
7245 | 340 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
341 |
7245 | 342 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
343 %! clf; |
7245 | 344 %! z = [0:0.05:5]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
345 %! plot3 (cos (2*pi*z), sin (2*pi*z), z, ';helix;'); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14335
diff
changeset
|
346 %! plot3 (z, exp (2i*pi*z), ';complex sinusoid;'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14184
diff
changeset
|
347 |