Mercurial > hg > octave-nkf
annotate scripts/plot/util/cla.m @ 20787:40ed9b46a800
new octave_value::string_value method with optional error message
* ov.h (octave_value::string_vector): New method.
ov-base.cc, ov-base.h (octave_base_value::string_vector):
New default method.
ov-str-mat.cc, ov-str-mat.h (octave_char_matrix_str::string_value):
New method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 16:43:22 -0400 |
parents | 42b7d7758c4a |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2008-2015 Ben Abbott |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
11104 | 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 ## | |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
20 ## @deftypefn {Command} {} cla |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
21 ## @deftypefnx {Command} {} cla reset |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## @deftypefnx {Function File} {} cla (@var{hax}) |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
23 ## @deftypefnx {Function File} {} cla (@var{hax}, "reset") |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
24 ## Clear the current axes. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
25 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
26 ## @code{cla} operates by deleting child graphic objects with visible |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
27 ## handles (HandleVisibility = @qcode{"on"}). |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
28 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
29 ## If the optional argument @qcode{"reset"} is specified, delete all child |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
30 ## objects including those with hidden handles and reset all axis properties |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
31 ## to their defaults. However, the following properties are not reset: |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
32 ## Position, Units. |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
33 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
34 ## If the first argument @var{hax} is an axes handle, then operate on |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
35 ## this axis rather than the current axes returned by @code{gca}. |
17443
0aa77acf22f5
doc: Add seealso references between cla, clf, reset functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
36 ## @seealso{clf, delete, reset} |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
37 ## @end deftypefn |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
38 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
39 ## Author: Ben Abbott <bpabbott@mac.com> |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
40 ## Created: 2008-10-03 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
41 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
42 function cla (varargin) |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
43 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
44 if (nargin > 2) |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
45 print_usage (); |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
46 elseif (nargin == 0) |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
47 hax = gca; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
48 do_reset = false; |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
49 elseif (nargin == 1) |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
50 if (isscalar (varargin{1}) && isaxes (varargin{1})) |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
51 hax = varargin{1}; |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
52 do_reset = false; |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
53 elseif (ischar (varargin{1}) && strcmpi (varargin{1}, "reset")) |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
54 hax = gca; |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
55 do_reset = true; |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
56 else |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
57 print_usage (); |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
58 endif |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
59 else |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
60 if (isscalar (varargin{1}) && isaxes (varargin{1}) |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
61 && ischar (varargin{2}) && strcmpi (varargin{2}, "reset")) |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
62 hax = varargin{1}; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
63 do_reset = true; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
64 else |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
65 print_usage (); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
66 endif |
8610
85c9906abfd1
use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents:
8285
diff
changeset
|
67 endif |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
68 |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
69 if (! do_reset) |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
70 delete (get (hax, "children")); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
71 else |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
72 __go_axes_init__ (hax, "replace"); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
73 __request_drawnow__ (); |
8264
bca580bbda02
cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents:
8199
diff
changeset
|
74 endif |
8199
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
75 |
ec1b4cd5fbbb
cla.m: Add matlab function cla().
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
76 endfunction |
8264
bca580bbda02
cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents:
8199
diff
changeset
|
77 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
78 |
8264
bca580bbda02
cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents:
8199
diff
changeset
|
79 %!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:
13111
diff
changeset
|
80 %! 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
|
81 %! unwind_protect |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
82 %! plot (1:10); |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
83 %! assert (! isempty (get (gca, "children"))); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
84 %! cla (); |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17081
diff
changeset
|
85 %! assert (isempty (get (gca, "children"))); |
8264
bca580bbda02
cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents:
8199
diff
changeset
|
86 %! unwind_protect_cleanup |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
87 %! close (hf); |
8264
bca580bbda02
cla.m: Fix error when no children to clear.
Ben Abbott <bpabbott@mac.com>
parents:
8199
diff
changeset
|
88 %! end_unwind_protect |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
89 |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
90 %!test |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
91 %! hf = figure ("visible", "off"); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
92 %! unwind_protect |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
93 %! hax = gca; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
94 %! plot (hax, 1:10); |
20496
42b7d7758c4a
Remove axes "interpreter" property (bug #45388)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
95 %! set (hax, "ticklabelinterpreter", "none"); |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
96 %! cla (hax); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
97 %! kids = get (hax, "children"); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
98 %! assert (numel (kids), 0); |
20496
42b7d7758c4a
Remove axes "interpreter" property (bug #45388)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
99 %! assert (get (hax, "ticklabelinterpreter"), "none"); |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
100 %! plot (hax, 1:10); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
101 %! cla (hax, "reset"); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
102 %! kids = get (hax, "children"); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
103 %! assert (numel (kids), 0); |
20496
42b7d7758c4a
Remove axes "interpreter" property (bug #45388)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19898
diff
changeset
|
104 %! assert (get (hax, "ticklabelinterpreter"), "tex"); |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
105 %! unwind_protect_cleanup |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
106 %! close (hf); |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
107 %! end_unwind_protect |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
108 |