annotate scripts/plot/draw/ezplot.m @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2008-2015 David Bateman
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
20 ## @deftypefn {Function File} {} ezplot (@var{f})
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
21 ## @deftypefnx {Function File} {} ezplot (@var{f2v})
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
22 ## @deftypefnx {Function File} {} ezplot (@var{fx}, @var{fy})
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
23 ## @deftypefnx {Function File} {} ezplot (@dots{}, @var{dom})
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 ## @deftypefnx {Function File} {} ezplot (@dots{}, @var{n})
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
25 ## @deftypefnx {Function File} {} ezplot (@var{hax}, @dots{})
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 ## @deftypefnx {Function File} {@var{h} =} ezplot (@dots{})
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 ##
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
28 ## Plot the 2-D curve defined by the function @var{f}.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
29 ##
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
30 ## The function @var{f} may be a string, inline function, or function handle
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
31 ## and can have either one or two variables. If @var{f} has one variable, then
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
32 ## the function is plotted over the domain @code{-2*pi < @var{x} < 2*pi}
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
33 ## with 500 points.
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
34 ##
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
35 ## If @var{f2v} is a function of two variables then the implicit function
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
36 ## @code{@var{f}(@var{x},@var{y}) = 0} is calculated over the meshed domain
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
37 ## @code{-2*pi <= @var{x} | @var{y} <= 2*pi} with 60 points in each dimension.
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
38 ##
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
39 ## For example:
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 ## @example
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
42 ## ezplot (@@(@var{x}, @var{y}) @var{x}.^2 - @var{y}.^2 - 1)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 ## @end example
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 ##
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
45 ## If two functions are passed as inputs then the parametric function
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
46 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 ## @example
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 ## @group
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
49 ## @var{x} = @var{fx} (@var{t})
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 ## @var{y} = @var{fy} (@var{t})
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 ## @end group
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 ## @end example
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 ##
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
54 ## @noindent
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
55 ## is plotted over the domain @code{-2*pi <= @var{t} <= 2*pi} with 500 points.
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 ## If @var{dom} is a two element vector, it represents the minimum and maximum
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
58 ## values of both @var{x} and @var{y}, or @var{t} for a parametric plot. If
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
59 ## @var{dom} is a four element vector, then the minimum and maximum values are
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
60 ## @code{[xmin xmax ymin ymax]}.
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
61 ##
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
62 ## @var{n} is a scalar defining the number of points to use in plotting
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 ## the function.
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
64 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 16993
diff changeset
65 ## If the first argument @var{hax} is an axes handle, then plot into this axis,
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 16993
diff changeset
66 ## rather than the current axes returned by @code{gca}.
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 16993
diff changeset
68 ## The optional return value @var{h} is a vector of graphics handles to
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 16993
diff changeset
69 ## the created line objects.
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
70 ##
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
71 ## @seealso{plot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh, ezmeshc, ezsurf, ezsurfc}
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
72 ## @end deftypefn
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
73
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
74 function h = ezplot (varargin)
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
75
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
76 [htmp, needusage] = __ezplot__ ("plot", varargin{:});
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
77
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
78 if (needusage)
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
79 print_usage ();
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
80 endif
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
81
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
82 if (nargout > 0)
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
83 h = htmp;
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 endif
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
85
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
86 endfunction
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
87
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
88
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
89 %!demo
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
90 %! %% sinc function using function handle
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
91 %! f = @(x) sin (pi*x) ./ (pi*x);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
92 %! ezplot (f);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
93
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
94 %!demo
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
95 %! %% example of a function string and explicit limits
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
96 %! clf;
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
97 %! ezplot ('1/x', [-2 2]);
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
98
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
99 %!demo
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
100 %! %% parameterized function example over -2*pi <= t <= +2*pi
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
101 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
102 %! ezplot (@cos, @sin);
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
103
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
104 %!demo
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17122
diff changeset
105 %! %% implicit function of 2 variables
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106 %! clf;
16993
78f57b14535c Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents: 14335
diff changeset
107 %! ezplot (inline ('x^2 - y^2 - 1'));
8046
c4482fc30c7f Add the ezplot function
David Bateman <dbateman@free.fr>
parents:
diff changeset
108