Mercurial > hg > octave-nkf
annotate scripts/plot/text.m @ 17531:bed7ec6f9855
scatter3.m: Turn off axis box for Matlab compatibility.
* scripts/plot/scatter3.m: Turn off axis box for Matlab compatibility.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 01 Oct 2013 15:51:28 -0700 |
parents | 96cf8ee3440e |
children | 4166048ba6cf |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 2007-2012 John W. Eaton |
6257 | 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. | |
6257 | 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/>. | |
6257 | 18 |
19 ## -*- texinfo -*- | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
20 ## @deftypefn {Function File} {} text (@var{x}, @var{y}, @var{string}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
21 ## @deftypefnx {Function File} {} text (@var{x}, @var{y}, @var{z}, @var{string}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
22 ## @deftypefnx {Function File} {} text (@dots{}, @var{prop}, @var{val}, @dots{}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{h} =} text (@dots{}) |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
24 ## Create a text object with text @var{string} at position @var{x}, @var{y}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
25 ## (@var{z}) on the current axes. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
26 ## |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
27 ## Multiple locations can be specified if @var{x}, @var{y}, (@var{z}) are |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
28 ## vectors. Multiple strings can be specified with a character matrix or |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
29 ## a cell array of strings. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
30 ## |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
31 ## Optional property/value pairs may be used to control the appearance of the |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
32 ## text. |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
33 ## |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
34 ## The optional return value @var{h} is a vector of graphics handles to the |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
35 ## created text objects. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
36 ## @seealso{gtext, title, xlabel, ylabel, zlabel} |
6257 | 37 ## @end deftypefn |
38 | |
39 ## Author: jwe | |
40 | |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
41 ## Note: The following code is rigged for Matlab compatibility and is |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
42 ## full of hidden assumptions. Be very wary when modifying. |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
43 |
6257 | 44 function h = text (varargin) |
45 | |
6405 | 46 nargs = nargin; |
47 offset = 0; | |
48 | |
49 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) | |
50 x = varargin{1}; | |
51 y = varargin{2}; | |
6257 | 52 |
53 if (nargin > 3 && isnumeric (varargin{3})) | |
54 z = varargin{3}; | |
55 offset = 4; | |
56 else | |
57 z = zeros (size (x)); | |
58 offset = 3; | |
59 endif | |
60 | |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
61 string = varargin{offset}; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
62 varargin(1:offset) = []; |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
63 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
64 nx = numel (x); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
65 ny = numel (y); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
66 nz = numel (z); |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
67 if (ischar (string)) |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
68 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
69 do_keyword_repl = true; |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
70 nt = rows (string); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
71 if (nx == 1 && nt == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
72 ## Single text object with one line |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
73 string = {string}; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
74 elseif (nx == 1 && nt > 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
75 ## Single text object with multiple lines |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
76 ## FIXME: "default" or "factory" as first row |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
77 ## should be escaped to "\default" or "\factory" |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
78 ## Other rows do not require escaping. |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
79 do_keyword_repl = false; |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
80 string = {string}; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
81 elseif (nx > 1 && nt == nx) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
82 ## Mutiple text objects with different strings |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
83 string = cellstr (string); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
84 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
85 ## Mutiple text objects with same string |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
86 string = repmat ({string}, [nx, 1]); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
87 nt = nx; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
88 endif |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
89 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
90 ## Escape special keywords |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
91 if (do_keyword_repl) |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
92 string = regexprep (string, '^(default|factory)$', '\\$1'); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
93 endif |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
94 |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
95 elseif (iscell (string)) |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
96 |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
97 nt = numel (string); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
98 if (nx == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
99 ## Single text object with one or more lines |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
100 string = {string}; |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
101 nt = 1; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
102 elseif (nx > 1 && nt == nx) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
103 ## Mutiple text objects with different strings |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
104 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
105 ## Mutiple text objects with same string |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
106 string = repmat ({string}, [nx, 1]); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
107 nt = nx; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
108 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
109 |
6257 | 110 else |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
111 |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
112 error ("text: STRING must be a character string or cell array of character strings"); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
113 |
6257 | 114 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
115 else # Only PROP/VALUE pairs |
6405 | 116 x = y = z = 0; |
117 nx = ny = nz = 1; | |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
118 string = {""}; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
119 nt = 1; |
6405 | 120 endif |
6257 | 121 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
122 ## Any remaining inputs must occur as PROPERTY/VALUE pairs |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
123 if (rem (numel (varargin), 2) != 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
124 print_usage (); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
125 endif |
6405 | 126 |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
127 ## Get axis argument which may be in a 'parent' PROP/VAL pair |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
128 [hax, varargin] = __plt_get_axis_arg__ ("text", varargin{:}); |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
129 |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
130 if (isempty (hax)) |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
131 hax = gca (); |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
132 endif |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
133 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
134 if (nx == ny && nx == nz && (nt == nx || nt == 1 || nx == 1)) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
135 pos = [x(:), y(:), z(:)]; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
136 htmp = zeros (nt, 1); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
137 if (nx == 1) |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
138 htmp = __go_text__ (hax, "string", string{1}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
139 varargin{:}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
140 "position", pos); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
141 elseif (nx == nt) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
142 for n = 1:nt |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
143 htmp(n) = __go_text__ (hax, "string", string{n}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
144 varargin{:}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
145 "position", pos(n,:)); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
146 endfor |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
147 __request_drawnow__ (); |
6405 | 148 else |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
149 error ("text: dimension mismatch for coordinates and STRING"); |
6405 | 150 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
151 elseif (nt == nx || nt == 1 || nx == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
152 error ("text: dimension mismatch for coordinates"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
153 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
154 error ("text: dimension mismatch between coordinates and strings"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
155 endif |
6257 | 156 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
157 if (nargout > 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
158 h = htmp; |
6257 | 159 endif |
160 | |
161 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
162 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
163 |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
164 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
165 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
166 %! ha = {'left', 'center', 'right'}; |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
167 %! va = {'bottom', 'middle', 'top'}; |
14249
27abe77158d6
Changes to allow plot demos to be converted and run by Matlab.
Ben Abbott <bpabbott@mac.com>
parents:
14245
diff
changeset
|
168 %! x = [0.25 0.5 0.75]; |
27abe77158d6
Changes to allow plot demos to be converted and run by Matlab.
Ben Abbott <bpabbott@mac.com>
parents:
14245
diff
changeset
|
169 %! y = x; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
170 %! for t = 0:30:359; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14249
diff
changeset
|
171 %! for nh = 1:numel (ha) |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14249
diff
changeset
|
172 %! for nv = 1:numel (va) |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
173 %! text (x(nh), y(nv), 'Hello World', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
174 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
175 %! 'horizontalalignment', ha{nh}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
176 %! 'verticalalignment', va{nv}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
177 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
178 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
179 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
180 %! set (gca, 'xtick', [0.25, 0.5, 0.75], ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
181 %! 'xticklabel', ha, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
182 %! 'ytick', [0.25, 0.5, 0.75], ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
183 %! 'yticklabel', va); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
184 %! axis ([0 1 0 1]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
185 %! xlabel ('horizontal alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
186 %! ylabel ('vertical alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
187 %! title ('text alignment and rotation (0:30:360 degrees)'); |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
188 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
189 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
190 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
191 %! h = mesh (peaks, 'edgecolor', 0.7 * [1 1 1], ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
192 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
193 %! 'facealpha', 0); |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
194 %! for t = 0:45:359; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
195 %! text (25, 25, 0, 'Vertical Alignment = Bottom', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
196 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
197 %! 'horizontalalignment', 'left', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
198 %! 'verticalalignment', 'bottom'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
199 %! end |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
200 %! caxis ([-100 100]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
201 %! title ('Vertically Aligned at Bottom'); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
202 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
203 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
204 %! clf; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
205 %! axis ([0 8 0 8]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
206 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
207 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
208 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
209 %! text (4, 4, {'Hello', 'World'}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
210 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
211 %! 'verticalalignment', 'middle'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
212 %! grid on; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
213 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
214 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
215 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
216 %! h = mesh (peaks (), 'edgecolor', 0.7 * [1 1 1], ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
217 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
218 %! 'facealpha', 0); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
219 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
220 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
221 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
222 %! zlabel (['1st zlabel';'2nd zlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
223 %! text (0, 0, 5, {'Hello', 'World'}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
224 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
225 %! 'verticalalignment', 'middle'); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
226 %! hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
227 %! plot3 (0, 0, 5, '+k'); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
228 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
229 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
230 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
231 %! h = text (0.5, 0.3, 'char'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
232 %! assert ('char', class (get (h, 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
233 %! h = text (0.5, 0.4, ['char row 1'; 'char row 2']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
234 %! assert ('char', class (get (h, 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
235 %! h = text (0.5, 0.6, {'cell2str (1,1)', 'cell2str (1,2)'; 'cell2str (2,1)', 'cell2str (2,2)'}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
236 %! assert ('cell', class (get (h, 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
237 %! h = text (0.5, 0.8, 'foobar'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
238 %! set (h, 'string', 1:3); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
239 %! h = text ([0.1, 0.1], [0.3, 0.4], 'one string & two objects'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
240 %! assert ('char', class (get (h(1), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
241 %! assert ('char', class (get (h(2), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
242 %! h = text ([0.1, 0.1], [0.5, 0.6], {'one cellstr & two objects'}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
243 %! assert ('cell', class (get (h(1), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
244 %! assert ('cell', class (get (h(2), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
245 %! h = text ([0.1, 0.1], [0.7, 0.8], {'cellstr 1 object 1', 'cellstr 2 object 2'}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
246 %! assert ('char', class (get (h(1), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
247 %! assert ('char', class (get (h(2), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
248 %! h = text ([0.1, 0.1], [0.1, 0.2], ['1st string & 1st object'; '2nd string & 2nd object']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
249 %! assert ('char', class (get (h(1), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
250 %! assert ('char', class (get (h(2), 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
251 %! h = text (0.7, 0.6, 'single string'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
252 %! assert ('char', class (get (h, 'string'))); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
253 %! h = text (0.7, 0.5, {'single cell-string'}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
254 %! assert ('cell', class (get (h, 'string'))); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
255 %! xlabel (1:2); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
256 %! ylabel (1:2); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
257 %! title (1:2); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
258 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
259 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
260 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13137
diff
changeset
|
261 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
262 %! ## Single object with one line |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
263 %! h = text (0.5, 0.3, "single object with one line"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
264 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
265 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
266 %! assert (obs, "single object with one line"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
267 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
268 %! ## Single object with multiple lines |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
269 %! h = text (0.5, 0.4, ["char row 1"; "char row 2"]); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
270 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
271 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
272 %! assert (obs, ["char row 1"; "char row 2"]); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
273 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
274 %! ## Multiple objects with single line |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
275 %! h = text ([0.1, 0.1], [0.3, 0.4], "two objects with same string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
276 %! assert (class (get (h(1), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
277 %! assert (class (get (h(2), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
278 %! assert (get (h(1), "string"), "two objects with same string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
279 %! assert (get (h(2), "string"), "two objects with same string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
280 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
281 %! ## Multiple objects with multiple lines |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
282 %! h = text ([0.1, 0.1], [0.3, 0.4], ["string1"; "string2"]); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
283 %! assert (class (get (h(1), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
284 %! assert (class (get (h(2), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
285 %! assert (get (h(1), "string"), "string1"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
286 %! assert (get (h(2), "string"), "string2"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
287 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
288 %! ### Tests repeated with cell input ### |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
289 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
290 %! ## Single object with one line |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
291 %! h = text (0.5, 0.3, {"single object with one line"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
292 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
293 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
294 %! assert (obs, {"single object with one line"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
295 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
296 %! ## Single object with multiple lines |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
297 %! h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
298 %! "cell2str (2,1)", "cell2str (2,2)"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
299 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
300 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
301 %! assert (obs, {"cell2str (1,1)"; "cell2str (2,1)"; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
302 %! "cell2str (1,2)"; "cell2str (2,2)"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
303 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
304 %! ## Multiple objects with single line |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
305 %! h = text ([0.1, 0.1], [0.5, 0.6], {"two objects with same cellstr"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
306 %! assert (class (get (h(1), "string")), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
307 %! assert (class (get (h(2), "string")), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
308 %! ## FIXME: is return value of cellstr, rather than string, Matlab-verified? |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
309 %! assert (get (h(1), "string"), {"two objects with same cellstr"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
310 %! assert (get (h(2), "string"), {"two objects with same cellstr"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
311 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
312 %! ## Multiple objects with multiple lines |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
313 %! h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr1", "cellstr2"}); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
314 %! ## FIXME: is return value really char in Matlab? |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
315 %! assert (class (get (h(1), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
316 %! assert (class (get (h(2), "string")), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
317 %! assert (get (h(1), "string"), "cellstr1"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
318 %! assert (get (h(2), "string"), "cellstr2"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
319 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
320 %! ## Test special keyword processing |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
321 %! h = text (0.5, 0.5, "default"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
322 %! assert (get (h, "string"), "default") |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
323 %! h = text (0.5, 0.5, "factory"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
324 %! assert (get (h, "string"), "factory") |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
325 %! |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
326 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
327 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
328 %! end_unwind_protect |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
329 |