Mercurial > hg > octave-lyh
annotate scripts/plot/ezplot.m @ 17475:fd01c78caa0b
Added tag ss-3-7-7 for changeset cc13924a4266
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Sep 2013 13:31:11 -0400 |
parents | df4c4b7708a4 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2008-2012 David Bateman |
8046 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
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 | 22 ## @deftypefnx {Function File} {} ezplot (@var{fx}, @var{fy}) |
23 ## @deftypefnx {Function File} {} ezplot (@dots{}, @var{dom}) | |
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 | 26 ## @deftypefnx {Function File} {@var{h} =} ezplot (@dots{}) |
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 | 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 | 40 ## |
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 | 43 ## @end example |
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 | 46 ## |
47 ## @example | |
48 ## @group | |
49 ## @var{x} = @var{fx} (@var{t}) | |
50 ## @var{y} = @var{fy} (@var{t}) | |
51 ## @end group | |
52 ## @end example | |
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 | 56 ## |
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 | 61 ## |
62 ## @var{n} is a scalar defining the number of points to use in plotting | |
63 ## the function. | |
64 ## | |
17126
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 | 67 ## |
17126
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 | 72 ## @end deftypefn |
73 | |
16993
78f57b14535c
Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents:
14335
diff
changeset
|
74 function h = ezplot (varargin) |
8046 | 75 |
16993
78f57b14535c
Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents:
14335
diff
changeset
|
76 [htmp, needusage] = __ezplot__ ("plot", varargin{:}); |
8046 | 77 |
78 if (needusage) | |
79 print_usage (); | |
80 endif | |
81 | |
82 if (nargout > 0) | |
16993
78f57b14535c
Overhaul ez* family of plot functions.
Rik <rik@octave.org>
parents:
14335
diff
changeset
|
83 h = htmp; |
8046 | 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 | 86 endfunction |
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 | 89 %!demo |
17198
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
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 |
17198
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
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 |
17198
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
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 | 103 |
104 %!demo | |
17198
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
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 | 108 |