annotate scripts/plot/draw/private/__ezplot__.m @ 19627:446c46af4b42 stable

strip trailing whitespace from most source files * Makefile.am, NEWS, build-aux/common.mk, configure.ac, doc/Makefile.am, doc/doxyhtml/Makefile.am, doc/interpreter/Makefile.am, doc/interpreter/arith.txi, doc/interpreter/audio.txi, doc/interpreter/basics.txi, doc/interpreter/bugs.txi, doc/interpreter/container.txi, doc/interpreter/cp-idx.txi, doc/interpreter/data.txi, doc/interpreter/debug.txi, doc/interpreter/diagperm.txi, doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README, doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/fn-idx.txi, doc/interpreter/func.txi, doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m, doc/interpreter/gpl.txi, doc/interpreter/grammar.txi, doc/interpreter/gui.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/interpimages.m, doc/interpreter/intro.txi, doc/interpreter/io.txi, doc/interpreter/java.txi, doc/interpreter/linalg.txi, doc/interpreter/macros.texi, doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl, doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi, doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1, doc/interpreter/octave.texi, doc/interpreter/oop.txi, doc/interpreter/op-idx.txi, doc/interpreter/optim.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/poly.txi, doc/interpreter/preface.txi, doc/interpreter/quad.txi, doc/interpreter/set.txi, doc/interpreter/signal.txi, doc/interpreter/sparse.txi, doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m, doc/interpreter/stats.txi, doc/interpreter/stmt.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/testfun.txi, doc/interpreter/tips.txi, doc/interpreter/var.txi, doc/interpreter/vectorize.txi, doc/liboctave/Makefile.am, doc/liboctave/array.texi, doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi, doc/liboctave/dae.texi, doc/liboctave/diffeq.texi, doc/liboctave/error.texi, doc/liboctave/factor.texi, doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi, doc/liboctave/install.texi, doc/liboctave/intro.texi, doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi, doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi, doc/liboctave/ode.texi, doc/liboctave/optim.texi, doc/liboctave/preface.texi, doc/liboctave/quad.texi, doc/liboctave/range.texi, doc/refcard/Makefile.am, doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2, etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog, etc/OLD-ChangeLogs/doc-ChangeLog, etc/OLD-ChangeLogs/scripts-ChangeLog, etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog, etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW, etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am, examples/@polynomial/end.m, examples/@polynomial/subsasgn.m, examples/Makefile.am, examples/standalonebuiltin.cc, libgui/Makefile.am, libgui/qterminal/libqterminal/README, libgui/qterminal/libqterminal/unix/BlockArray.cpp, libgui/qterminal/libqterminal/unix/BlockArray.h, libgui/qterminal/libqterminal/unix/Character.h, libgui/qterminal/libqterminal/unix/CharacterColor.h, libgui/qterminal/libqterminal/unix/Emulation.cpp, libgui/qterminal/libqterminal/unix/Emulation.h, libgui/qterminal/libqterminal/unix/Filter.cpp, libgui/qterminal/libqterminal/unix/Filter.h, libgui/qterminal/libqterminal/unix/History.cpp, libgui/qterminal/libqterminal/unix/History.h, libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp, libgui/qterminal/libqterminal/unix/KeyboardTranslator.h, libgui/qterminal/libqterminal/unix/LineFont.h, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h, libgui/qterminal/libqterminal/unix/Screen.cpp, libgui/qterminal/libqterminal/unix/Screen.h, libgui/qterminal/libqterminal/unix/ScreenWindow.cpp, libgui/qterminal/libqterminal/unix/ScreenWindow.h, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h, libgui/qterminal/libqterminal/unix/Vt102Emulation.h, libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp, libgui/qterminal/qterminal/main.cpp, libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc, libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy, libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc, libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl, libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add, libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs, libinterp/mkops, libinterp/octave-value/ov-java.cc, libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/octave.gperf, liboctave/Makefile.am, liboctave/array/Array.cc, liboctave/array/module.mk, liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f, liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f, liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f, liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f, liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f, liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f, liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f, liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f, liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f, liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f, liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f, liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f, liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f, liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f, liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f, liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f, liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk, liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f, liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f, liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f, liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f, liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f, liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc, liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f, liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f, liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f, liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f, liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc, liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for, liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f, liboctave/cruft/slatec-fn/datanh.f, liboctave/cruft/slatec-fn/xgmainc.f, liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk, liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops, liboctave/operators/sparse-mk-ops.awk, liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops, liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m, scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m, scripts/deprecated/java_new.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m, scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m, scripts/general/display.m, scripts/general/fieldnames.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/isa.m, scripts/general/methods.m, scripts/general/sortrows.m, scripts/geometry/convhull.m, scripts/geometry/delaunay.m, scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m, scripts/geometry/griddata.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/gui/guihandles.m, scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m, scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m, scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m, scripts/image/bone.m, scripts/image/cmpermute.m, scripts/image/cmunique.m, scripts/image/colorcube.m, scripts/image/colormap.m, scripts/image/contrast.m, scripts/image/gray2ind.m, scripts/image/image.m, scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/java_get.m, scripts/java/java_set.m, scripts/java/javaaddpath.m, scripts/java/javaclasspath.m, scripts/java/javamem.m, scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m, scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m, scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m, scripts/mk-pkg-add, scripts/mkdoc.pl, scripts/optimization/fminsearch.m, scripts/optimization/optimset.m, scripts/optimization/sqp.m, scripts/pkg/pkg.m, scripts/pkg/private/create_pkgadddel.m, scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m, scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m, scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m, scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m, scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m, scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m, scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m, scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m, scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m, scripts/plot/draw/private/__errplot__.m, scripts/plot/draw/private/__ezplot__.m, scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m, scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m, scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m, scripts/plot/util/clf.m, scripts/plot/util/copyobj.m, scripts/plot/util/figure.m, scripts/plot/util/gcbo.m, scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m, scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m, scripts/plot/util/print.m, scripts/plot/util/private/__add_default_menu__.m, scripts/plot/util/private/__fltk_print__.m, scripts/plot/util/private/__gnuplot_print__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m, scripts/polynomial/conv.m, scripts/polynomial/poly.m, scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m, scripts/polynomial/polyval.m, scripts/polynomial/private/__splinefit__.m, scripts/polynomial/spline.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m, scripts/prefs/rmpref.m, scripts/signal/freqz.m, scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m, scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/specfun/expint.m, scripts/specfun/factor.m, scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m, scripts/special-matrix/toeplitz.m, scripts/startup/inputrc, scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m, scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m, scripts/statistics/distributions/betarnd.m, scripts/statistics/distributions/binoinv.m, scripts/statistics/distributions/binopdf.m, scripts/statistics/distributions/binornd.m, scripts/statistics/distributions/cauchy_rnd.m, scripts/statistics/distributions/chi2rnd.m, scripts/statistics/distributions/discrete_pdf.m, scripts/statistics/distributions/discrete_rnd.m, scripts/statistics/distributions/empirical_rnd.m, scripts/statistics/distributions/exprnd.m, scripts/statistics/distributions/frnd.m, scripts/statistics/distributions/gamrnd.m, scripts/statistics/distributions/geornd.m, scripts/statistics/distributions/hygernd.m, scripts/statistics/distributions/kolmogorov_smirnov_cdf.m, scripts/statistics/distributions/laplace_cdf.m, scripts/statistics/distributions/laplace_pdf.m, scripts/statistics/distributions/logistic_cdf.m, scripts/statistics/distributions/logistic_pdf.m, scripts/statistics/distributions/lognrnd.m, scripts/statistics/distributions/nbincdf.m, scripts/statistics/distributions/nbininv.m, scripts/statistics/distributions/nbinpdf.m, scripts/statistics/distributions/nbinrnd.m, scripts/statistics/distributions/normrnd.m, scripts/statistics/distributions/poissinv.m, scripts/statistics/distributions/poissrnd.m, scripts/statistics/distributions/tinv.m, scripts/statistics/distributions/trnd.m, scripts/statistics/distributions/unidcdf.m, scripts/statistics/distributions/unidpdf.m, scripts/statistics/distributions/unidrnd.m, scripts/statistics/distributions/unifrnd.m, scripts/statistics/distributions/wblrnd.m, scripts/statistics/models/module.mk, scripts/statistics/tests/kruskal_wallis_test.m, scripts/strings/base2dec.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjoin.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m, scripts/testfun/test.m, scripts/time/asctime.m, scripts/time/datenum.m, scripts/time/datevec.m, scripts/time/weekday.m, src/Makefile.am, test/Makefile.am, test/build-bc-overload-tests.sh, test/build-sparse-tests.sh, test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 08:26:57 -0500
parents d63878346099
children 0e1f5a750d00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17572
diff changeset
1 ## Copyright (C) 2007-2013 David Bateman
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
2 ##
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
4 ##
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
9 ##
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
14 ##
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8046
diff changeset
19 ## -*- texinfo -*-
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
20 ## @deftypefn {Function File} {[@var{h}, @var{needusage}] =} __ezplot__ (@var{pltfunc}, @var{varargin})
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8046
diff changeset
21 ## Undocumented internal function.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8046
diff changeset
22 ## @end deftypefn
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
23
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
24 ## Overview: This function is the back-end for the 9 ez* plot functions.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
25 ## As such, most of the function is actually dedicated to sorting
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
26 ## out the inputs and verifying that the particular ez* function
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
27 ## called was called correctly. The actual plotting occurs near
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
28 ## the end in an unwind_protect block.
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
29
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
30 function [h, needusage] = __ezplot__ (pltfunc, varargin)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
31
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
32 ezfunc = ["ez" pltfunc];
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
33
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
34 [hax, varargin, nargin] = __plt_get_axis_arg__ (ezfunc, varargin{:});
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
35
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
36 ## Define outputs early in case of shorting out of function with return;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
37 h = [];
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
38 needusage = false;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
39 if (nargin < 1)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
40 needusage = true;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
41 return;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
42 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
43
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
44 iscontour = strncmp (pltfunc, "contour", 7);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
45
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
46 ## Defaults for ezplot
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
47 isplot = true;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
48 isplot3 = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
49 ispolar = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
50 nargs = 1;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
51 switch (pltfunc)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
52 case "plot"
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
53 ## defaults already set
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
54
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
55 case "plot3"
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
56 isplot = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
57 isplot3 = true;
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
58
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
59 case "polar"
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
60 isplot = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
61 ispolar = true;
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
62
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
63 otherwise
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
64 ## contour, mesh, surf plots
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
65 isplot = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
66 nargs = 2;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
67
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
68 endswitch
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
69
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
70 parametric = false;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
71 fun = varargin{1};
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
72 if (ischar (fun))
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
73 if (exist (fun, "file") || exist (fun, "builtin"))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
74 fun = inline ([fun "(t)"]);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
75 else
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
76 fun = vectorize (inline (fun));
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
77 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
78 argids = argnames (fun);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
79 if (isplot && length (argids) == 2)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
80 nargs = 2;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
81 elseif (numel (argids) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
82 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
83 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
84 fstr = formula (fun);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
85 if (isplot)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
86 xarg = argids{1};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
87 if (nargs == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
88 yarg = argids{2};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
89 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
90 yarg = "";
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
91 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
92 elseif (isplot3)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
93 xarg = "x";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
94 yarg = "y";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
95 elseif (ispolar)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
96 xarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
97 yarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
98 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
99 xarg = argids{1};
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
100 yarg = argids{2};
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
101 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
102 elseif (strcmp (typeinfo (fun), "inline function"))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
103 argids = argnames (fun);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
104 if (isplot && length (argids) == 2)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
105 nargs = 2;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
106 elseif (numel (argids) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
107 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
108 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
109 fun = vectorize (fun);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
110 fstr = formula (fun);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
111 if (isplot)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
112 xarg = argids{1};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
113 if (nargs == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
114 yarg = argids{2};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
115 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
116 yarg = "";
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
117 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
118 elseif (isplot3)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
119 xarg = "x";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
120 yarg = "y";
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
121 elseif (isplot || ispolar)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
122 xarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
123 yarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
124 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
125 xarg = argids{1};
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
126 yarg = argids{2};
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
127 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
128 elseif (isa (fun, "function_handle"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
129 fstr = func2str (fun);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
130 idx = index (fstr, ')');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
131 if (idx != 0)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
132 args = regexp (fstr(3:(idx-1)), '\w+', 'match');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
133 fstr = fstr(idx+2:end); # remove '@(x) ' from string name
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
134 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
135 args = {"x"};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
136 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
137 if (isplot && length (args) == 2)
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
138 nargs = 2;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
139 elseif (numel (args) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
140 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
141 endif
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
142 if (isplot)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
143 xarg = args{1};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
144 if (nargs == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
145 yarg = args{2};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
146 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
147 yarg = "";
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
148 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
149 elseif (isplot3)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
150 xarg = "x";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
151 yarg = "y";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
152 elseif (ispolar)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
153 xarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
154 yarg = "";
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
155 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
156 xarg = args{1};
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
157 yarg = args{2};
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
158 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
159 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
160 error ("%s: expecting string, inline function, or function handle", ezfunc);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
161 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
162
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
163 if (nargin > 2 || (nargin == 2 && isplot))
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
164 funx = fun;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
165 fstrx = fstr;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
166 funy = varargin{2};
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
167 if (ischar (funy) && ! strcmp (funy, "circ") && ! strcmp (funy, "animate"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
168 parametric = true;
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
169 if (exist (funy, "file") || exist (funy, "builtin"))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
170 funy = inline ([funy "(t)"]);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
171 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
172 funy = vectorize (inline (funy));
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
173 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
174 if (numel (argnames (funy)) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
175 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
176 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
177 fstry = formula (funy);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
178 elseif (strcmp (typeinfo (funy), "inline function"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
179 parametric = true;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
180 if (numel (argnames (funy)) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
181 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
182 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
183 funy = vectorize (funy);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
184 fstry = formula (funy);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
185 elseif (isa (funy, "function_handle"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
186 parametric = true;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
187 fstry = func2str (funy);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
188 idx = index (fstry, ')');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
189 if (idx != 0)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
190 args = regexp (fstry(3:(idx-1)), '\w+', 'match');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
191 fstry = fstry(idx+2:end); # remove '@(x) ' from string name
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
192 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
193 args = {"y"};
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
194 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
195 if (numel (args) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
196 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
197 endif
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
198 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
199
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
200 if (! parametric && isplot3)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
201 needusage = true; # Can't call non-parametric ezplot3
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
202 return;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
203 elseif (parametric && isplot)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
204 if (nargs == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
205 error ("%s: can not define a parametric function in this manner", ezfunc);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
206 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
207 xarg = "x";
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
208 yarg = "y";
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
209 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
210 elseif (parametric)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
211 funz = varargin{3};
11149
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 11032
diff changeset
212 if (ischar (funz) && ! strcmp (funz, "circ")
fe3c3dfc07eb style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents: 11032
diff changeset
213 && ! strcmp (funz, "animate"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
214 if (exist (funz, "file") || exist (funz, "builtin"))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
215 funz = inline ([funz "(t)"]);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
216 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
217 funz = vectorize (inline (funz));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
218 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
219 if (numel (argnames (funz)) > nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
220 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
221 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
222 fstrz = formula (funz);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
223 elseif (strcmp (typeinfo (funz), "inline function"))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
224 if (numel (argnames (funz)) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
225 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
226 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
227 funz = vectorize (funz);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
228 fstrz = formula (funz);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
229 elseif (isa (funz, "function_handle"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
230 fstrz = func2str (funz);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
231 idx = index (fstrz, ')');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
232 if (idx != 0)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
233 args = regexp (fstrz(3:(idx-1)), '\w+', 'match');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
234 fstrz = fstrz(idx+2:end); # remove '@(x) ' from string name
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
235 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
236 args = {"z"};
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
237 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
238 if (numel (args) != nargs)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
239 error ("%s: expecting a function of %d arguments", ezfunc, nargs);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
240 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
241 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
242 error ("%s: parametric plots expect 3 functions", ezfunc);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
243 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
244 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
245 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
246
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
247 if ((isplot && nargs != 2) || isplot3 || ispolar)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
248 n = 500; # default for point-style functions like plot
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
249 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
250 n = 60; # default for meshgrid style functions like contour, surf
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
251 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
252 domain = [];
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
253 circ = false;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
254 animate = false;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
255 if (parametric)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
256 if (isplot)
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
257 iarg = 3;
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
258 else
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
259 iarg = 4;
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
260 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
261 else
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
262 iarg = 2;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
263 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
264 while (iarg <= nargin)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
265 arg = varargin{iarg++};
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
266 if (ischar (arg) && strcmp (arg, "circ"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
267 circ = true;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
268 elseif (ischar (arg) && strcmp (arg, "animate"))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
269 animate = true;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
270 elseif (isscalar (arg))
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
271 n = arg;
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
272 elseif (numel (arg) == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
273 domain = [arg(1) arg(2) arg(1) arg(2)];
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
274 elseif (numel (arg) == 4)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
275 domain = arg(:).';
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
276 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
277 error ("%s: expecting scalar, 2-, or 4-element vector", ezfunc);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
278 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
279 endwhile
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
280
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
281 if (circ && (iscontour || isplot3 || isplot))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
282 needusage = true;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
283 return;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
284 elseif (circ && parametric)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
285 error ("%s: can not have both circular domain and parametric function",
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
286 ezfunc);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
287 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
288
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
289 if (animate && ! isplot3)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
290 error ("%s: animate option only valid for ezplot3", ezfunc);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
291 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
292
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
293 if (parametric)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
294 ## Make the label strings pretty by removing extra spaces between base
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
295 ## and exponent, the '.' in vectorized code, and the '*' for multiply.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
296 fstrx = regexprep (regexprep (regexprep (fstrx,
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
297 '\s*\.?(?:\^|\*\*)\s*','^'), '\.([/+-])', '$1'), '\s*\.?\*\s*', ' ');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
298 fstry = regexprep (regexprep (regexprep (fstry,
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
299 '\s*\.?(?:\^|\*\*)\s*','^'), '\.([/+-])', '$1'), '\s*\.?\*\s*', ' ');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
300 if (isplot)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
301 fstr = ["x = " fstrx ", y = " fstry];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
302 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
303 fstrz = regexprep (regexprep (regexprep (fstrz,
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
304 '\s*\.?(?:\^|\*\*)\s*','^'), '\.([/+-])', '$1'), '\s*\.?\*\s*', ' ');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
305 fstr = ["x = " fstrx ",y = " fstry ", z = " fstrz];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
306 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
307 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
308 fstr = regexprep (regexprep (regexprep (fstr,
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
309 '\s*\.?(?:\^|\*\*)\s*','^'), '\.([/+-])', '$1'), '\s*\.?\*\s*', ' ');
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
310 if (isplot && nargs == 2)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
311 fstr = [fstr " = 0"]; # make title string of implicit function
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
312 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
313 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
314
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
315 if (isempty (domain))
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
316 auto_domain = true;
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
317 if (isplot3 || ispolar)
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
318 domain = [0, 2*pi, 0, 2*pi];
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
319 else
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
320 domain = [-2*pi, 2*pi, -2*pi, 2*pi];
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
321 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
322 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
323 auto_domain = false;
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
324 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
325
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
326 auto_domain_done = false;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
327 do
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
328 domain_ok = true;
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
329
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
330 if ((isplot && nargs == 1) || isplot3 || ispolar)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
331 X = linspace (domain(1), domain(2), n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
332 elseif (isplot && numel (domain) == 2)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
333 x = linspace (domain(1), domain(2), n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
334 [X, Y] = meshgrid (x, x);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
335 elseif (circ)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
336 ## To plot on circular domain develop grid in polar coordinates
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
337 ## and then switch these to Cartesian coordinates.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
338 cent = [domain(1) + domain(2), domain(3) + domain(4)] / 2;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
339 rmax = sqrt ((domain(2) - cent(1))^2 + (domain(4) - cent(2))^2);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
340 r = linspace (0, rmax, n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
341 t = linspace (0, 2*pi, n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
342 [T, R] = meshgrid (t, r);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
343 X = R .* cos (T) + cent(1);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
344 Y = R .* sin (T) + cent(2);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
345 domain = [-rmax+cent(1), +rmax+cent(1), -rmax+cent(2), +rmax+cent(2)];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
346 else # contour, mesh, surf plots
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
347 x = linspace (domain(1), domain(2), n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
348 y = linspace (domain(3), domain(4), n);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
349 [X, Y] = meshgrid (x, y);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
350 endif
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
351
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
352 if (parametric)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
353 if (isplot)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
354 XX = feval (funx, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
355 Z = feval (funy, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
356 X = XX;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
357 elseif (isplot3)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
358 Z = feval (funz, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
359 XX = feval (funx, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
360 YY = feval (funy, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
361 X = XX;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
362 Y = YY;
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
363 else
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
364 Z = feval (funz, X, Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
365 XX = feval (funx, X, Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
366 YY = feval (funy, X, Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
367 X = XX;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
368 Y = YY;
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
369
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
370 ## Eliminate the singularities
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
371 X = __eliminate_sing__ (X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
372 Y = __eliminate_sing__ (Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
373 Z = __eliminate_sing__ (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
374 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
375 else ## non-parametric plots
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
376 if (isplot && nargs == 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
377 Z = feval (fun, X, Y);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
378
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
379 ## Matlab returns line objects for this case and so can't call
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
380 ## contour directly as it returns patch objects to allow colormaps
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
381 ## to work with contours. Therefore recreate the lines from the
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
382 ## output for contourc, and store in cell arrays.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
383 [c, ~] = contourc (X, Y, Z, [0, 0]);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
384
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
385 i = 1;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
386 XX = YY = {};
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
387 while (i < length (c))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
388 clev = c(1,i);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
389 clen = c(2,i);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
390 XX = [XX, {c(1, i+1:i+clen)}];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
391 YY = [YY, {c(2, i+1:i+clen)}];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
392 i += clen+1;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
393 endwhile
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
394 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
395 if (ispolar)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
396 Z = feval (fun, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
397 ## FIXME: Why aren't singularities eliminated for polar plots?
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
398 elseif (isplot)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
399 Z = feval (fun, X);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
400 ## Eliminate the singularities
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
401 Z = __eliminate_sing__ (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
402 domain = find_valid_domain (X, [], Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
403 elseif (iscontour)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
404 Z = feval (fun, X, Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
405 Z = __eliminate_sing__ (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
406 else # mesh, surf plots
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
407 Z = feval (fun, X, Y);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
408 Z = __eliminate_sing__ (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
409 if (circ)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
410 ## Use domain calculated at the start.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
411 ## The X, Y grids are non-monotonic after conversion from polar
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
412 ## coordinates and find_valid_domain fails.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
413
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
414 elseif (auto_domain && ! auto_domain_done)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
415 valid_domain = find_valid_domain (X, Y, Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
416 domain_ok = isequal (domain, valid_domain);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
417 domain = valid_domain;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
418 auto_domain_done = true; # ensures only 1 round of do loop done
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
419 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
420 if (! auto_domain_done)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
421 domain = find_valid_domain (X, Y, Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
422 endif
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17301
diff changeset
423 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
424 endif
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
425 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
426 endif
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
427 until (domain_ok)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
428
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
429 ## Now, actually call the correct plot function with valid data and domain.
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17167
diff changeset
430 oldfig = [];
17301
68bcac3c043a Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents: 17211
diff changeset
431 if (! isempty (hax))
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17167
diff changeset
432 oldfig = get (0, "currentfigure");
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17167
diff changeset
433 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
434 unwind_protect
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
435 hax = newplot (hax);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
436 if (iscontour)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
437 [~, h] = feval (pltfunc, hax, X, Y, Z);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
438 elseif (isplot && nargs == 2)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
439 h = zeros (length (XX), 1);
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
440 hold_state = get (hax, "nextplot");
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
441 for i = 1 : length (XX)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
442 h(i) = plot(hax, XX{i}, YY{i});
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
443 if (i == 1)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
444 set (hax, "nextplot", "add");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
445 endif
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
446 endfor
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
447 set (hax, "nextplot", hold_state);
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
448 axis (hax, domain);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
449 elseif (isplot || ispolar)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
450 h = feval (pltfunc, hax, X, Z);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
451 if (isplot && ! parametric)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
452 axis (hax, domain);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
453 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
454 elseif (isplot3)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
455 if (animate)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
456 ## draw animation, then replace with true plot3
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
457 comet3 (hax, X, Y, Z, .05);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents: 7540
diff changeset
458 endif
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
459 h = feval (pltfunc, hax, X, Y, Z);
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
460 set (hax, "box", "off");
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
461 grid (hax, "on");
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
462 zlabel (hax, "z");
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
463 else # mesh and surf plots
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
464 h = feval (pltfunc, hax, X, Y, Z);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
465 ## FIXME: surf, mesh should really do a better job of setting zlim
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
466 if (! parametric)
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
467 axis (hax, domain);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
468 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
469 endif
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
470 xlabel (hax, xarg);
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
471 ylabel (hax, yarg);
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
472 title (hax, fstr);
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
473 unwind_protect_cleanup
17054
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
474 if (! isempty (oldfig))
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
475 set (0, "currentfigure", oldfig);
27b3a675ea6b __ezplot__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16993
diff changeset
476 endif
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
477 end_unwind_protect
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
478
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
479 endfunction
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
480
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
481 ## Eliminate bad data (complex values, infinities, singularities)
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
482 function x = __eliminate_sing__ (x)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
483 if (iscomplex (x))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
484 x(imag (x) != 0) = NaN;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
485 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
486 x(isinf (x)) = NaN;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
487 ## High rates of curvature are treated as singularities
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
488 threshold = 0.2 * (max (x(:)) - min (x(:)));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
489 x(abs (del2 (x)) > threshold) = NaN;
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents:
diff changeset
490 endfunction
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
491
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
492 ## Find: 1) range of function where there are not NaN values,
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
493 ## 2) function is changing (not just flat surface)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
494 function domain = find_valid_domain (X, Y, Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
495
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
496 if (isvector (Z))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
497 ## 2-D data for isplot
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
498 domain = [X(1) X(end)];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
499
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
500 ## Guess a range which includes the "mass" of the data by using a
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
501 ## median-based approach. The center 3/4 of the data is used to
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
502 ## determine the range of the data.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
503 ## This seems to be vaguely what Matlab does, but can't be sure.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
504 XX = sort (Z(isfinite (Z)));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
505 if (length (X) > 4)
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
506 irlo = XX(fix (1/8 * length (XX)));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
507 irhi = XX(fix (7/8 * length (XX)));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
508 d = irhi - irlo;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
509 domain(3) = max (XX(1) - d/8, irlo - d);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
510 domain(4) = min (XX(end) + d/8, irhi + d);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
511 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
512 domain(3:4) = [XX(1), XX(end)];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
513 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
514
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
515 #{
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
516 ## FIXME: Old algorithm for removing singularities
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
517 ## Deprecated in 3.8. Can be removed if no problems appear in ezplot.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
518 idx = 2 : length (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
519 idx = find (((Z(idx) > yrange(2) / 2) & (Z(idx-1) < yrange(1) / 2)) |
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
520 ((Z(idx) < yrange(1) / 2) & (Z(idx-1) > yrange(2) / 2)));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
521 Z(idx) = NaN;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
522 #}
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
523
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
524 else
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
525 ## 3-D data such as mesh, surf
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
526 Zfinite = ! isnan (Z);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
527 Zrows = any (Zfinite, 2);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
528 rmin = find (Zrows, 1, "first");
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
529 rmax = find (Zrows, 1, "last");
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
530 Zcols = any (Zfinite, 1);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
531 cmin = find (Zcols, 1, "first");
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
532 cmax = find (Zcols, 1, "last");
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
533
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
534 ## Handle nasty case of all NaNs
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
535 if (isempty (rmin))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
536 rmin = 1, rmax = rows (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
537 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
538 if (isempty (cmin))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
539 cmin = 1, cmax = columns (Z);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
540 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
541
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
542 if ( ! any (isnan (Z([rmin, rmax],:)(:)))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
543 && ! any (isnan (Z(:, [cmin, cmax])(:))))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
544 ## Exclude surfaces along borders which are flat (gradient =~ 0).
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
545 ## Technically, this calculation might be better done with actual
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
546 ## deltaX, deltaY values. But, data is usually meshgridded
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
547 ## (constant spacing) so working with deltaROW#, deltaCOL# is fine.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
548 [Zx, Zy] = gradient (Z(rmin:rmax, cmin:cmax));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
549 Zgrad = sqrt (Zx.^2 + Zy.^2);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
550 slope = ((max (Z(:)) - min (Z(:)))
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
551 / sqrt ((rmax - rmin)^2 + (cmax - cmin)^2));
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
552 slope /= 125; # threshold for discarding points.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
553 Zrows = any (Zgrad > slope, 2);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
554 rmin += find (Zrows, 1, "first") - 1;
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
555 rmax += find (Zrows, 1, "last") - rows (Zrows);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
556 Zcols = any (Zgrad > slope, 1);
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
557 cmin += find (Zcols, 1, "first") - 1;
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
558 cmax += find (Zcols, 1, "last") - columns (Zcols);
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
559 endif
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
560
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
561 domain = [X(1,cmin) X(1,cmax) Y(rmin,1) Y(rmax,1)];
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
562 endif
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
563
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
564 endfunction
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14868
diff changeset
565