Mercurial > hg > octave-lyh
annotate scripts/plot/semilogy.m @ 13979:f35b593688a5
Changing the legend's interpreter property should be inherited by the
legend's labels (Fix bug #34342).
* scripts/plot/__go_draw_axes__.m: Add no_tex() to escape "_" & "^".
* scripts/plot/legend.m: Fix the text labels updater. Warn if extra
entries are present. Add demos and fix others.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 02 Dec 2011 19:42:42 -0500 |
parents | d67c8bf52e20 |
children | 5f0bb45e615c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1993-2011 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
245 | 18 |
3368 | 19 ## -*- texinfo -*- |
10730
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
20 ## @deftypefn {Function File} {} semilogy (@var{y}) |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
21 ## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}) |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
22 ## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
23 ## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}, @var{fmt}) |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
24 ## @deftypefnx {Function File} {} semilogy (@var{h}, @dots{}) |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
25 ## @deftypefnx {Function File} {@var{h} =} semilogy (@dots{}) |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10647
diff
changeset
|
26 ## Produce a two-dimensional plot using a logarithmic scale for the @var{y} |
10730
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
27 ## axis. See the documentation of @code{plot} for a description of the |
6895 | 28 ## arguments that @code{semilogy} will accept. |
29 ## @seealso{plot, semilogx, loglog} | |
3368 | 30 ## @end deftypefn |
4 | 31 |
2314 | 32 ## Author: jwe |
33 | |
6302 | 34 function retval = semilogy (varargin) |
4 | 35 |
10730
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
36 [h, varargin, nargs] = __plt_get_axis_arg__ ("semilogy", varargin{:}); |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
37 |
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
38 if (nargs < 1) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
39 print_usage(); |
10730
390d93e20531
Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
40 endif |
7216 | 41 |
7207 | 42 oldh = gca (); |
43 unwind_protect | |
44 axes (h); | |
45 newplot (); | |
3063 | 46 |
7207 | 47 set (h, "yscale", "log"); |
10647
5c6b73a844e4
Plot minor ticks for semilog plots
Rik <octave@nomad.inbox5.com>
parents:
7216
diff
changeset
|
48 if (any( strcmp (get (gca, "nextplot"), {"new", "replace"}))) |
5c6b73a844e4
Plot minor ticks for semilog plots
Rik <octave@nomad.inbox5.com>
parents:
7216
diff
changeset
|
49 set (h, "yminortick", "on"); |
5c6b73a844e4
Plot minor ticks for semilog plots
Rik <octave@nomad.inbox5.com>
parents:
7216
diff
changeset
|
50 endif |
4 | 51 |
7207 | 52 tmp = __plt__ ("semilogy", h, varargin{:}); |
6302 | 53 |
7207 | 54 if (nargout > 0) |
55 retval = tmp; | |
56 endif | |
57 | |
58 unwind_protect_cleanup | |
59 axes (oldh); | |
60 end_unwind_protect | |
4 | 61 |
62 endfunction | |
13090
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
63 |
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
64 %!demo |
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
65 %! x = 1:0.01:10; |
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
66 %! y = (x .* (1 + rand (size (x)))) .^ 2; |
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
67 %! semilogy (x, y); |
7f127e079a7c
codesprint: demos for semilogx, semilogy, and loglog
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
68 |
13103
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
69 %!demo |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
70 %! clf (); |
13783
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
71 %! x = logspace (-5, 1, 10); |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
72 %! y = logspace (-5, 1, 10); |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
73 %! |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
74 %! subplot (2, 1, 1) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
75 %! semilogy (x, y) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
76 %! ylabel ('semilogy (x, y)') |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
77 %! |
13783
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
78 %! subplot (2, 1, 2) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
79 %! semilogy (x, -y) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
80 %! ylabel ('semilogy (x, -y)') |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
81 |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
82 %!demo |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
83 %! clf (); |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
84 %! x = logspace (-5, 1, 10); |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
85 %! y = logspace (-5, 1, 10); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
86 %! |
13783
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
87 %! subplot (2, 1, 1) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
88 %! semilogy (x, y) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
89 %! set (gca, "ydir", "reverse", "activepositionproperty", "outerposition") |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
90 %! ylabel ({"semilogy (x, y)", "ydir = reversed"}) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
91 %! |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
92 %! subplot (2, 1, 2) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
93 %! semilogy (x, -y) |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
94 %! set (gca, "ydir", "reverse", "activepositionproperty", "outerposition") |
d67c8bf52e20
Minor improvements to semilogx and semilogy demos.
Ben Abbott <bpabbott@mac.com>
parents:
13141
diff
changeset
|
95 %! ylabel ({"semilogy (x, -y)", "ydir = reversed"}) |
13103
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
96 |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
97 %!test |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13104
diff
changeset
|
98 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
99 %! unwind_protect |
13103
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
100 %! a = logspace (-5, 1, 10); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
101 %! b = logspace (-5, 1, 10); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
102 %! semilogy (a, b) |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
103 %! assert (get (gca, "yscale"), "log"); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
104 %! assert (get (gca, "xscale"), "linear"); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
105 %! unwind_protect_cleanup |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
106 %! close (hf); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
107 %! end_unwind_protect |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
108 |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
109 %!test |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13104
diff
changeset
|
110 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
111 %! unwind_protect |
13103
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
112 %! a = logspace (-5, 1, 10); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
113 %! b =-logspace (-5, 1, 10); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
114 %! semilogy (a, b) |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
115 %! axis tight |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
116 %! assert (all (get (gca, "ytick") < 0)); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
117 %! unwind_protect_cleanup |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
118 %! close (hf); |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
119 %! end_unwind_protect |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
120 |
2e2738837a24
Add tests and demos for log-scale plotting functions
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13090
diff
changeset
|
121 |