Mercurial > hg > octave-nkf
annotate scripts/plot/appearance/text.m @ 19016:87c3848cf3c0
Fix bug when hggroup used with primitive graphic object (bug #42532).
* image.m, text.m, line.m, patch.m: __plt_get_axis_arg__ will return axis and
hggroup when 'parent' property is used. Select the first returned object
which is the axes, rather than passing both axis and hggroup to further plot
subroutines.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 10 Jun 2014 14:03:09 -0700 |
parents | d63878346099 |
children | 0e1f5a750d00 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17572
diff
changeset
|
1 ## Copyright (C) 2007-2013 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 (); |
19016
87c3848cf3c0
Fix bug when hggroup used with primitive graphic object (bug #42532).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 else |
87c3848cf3c0
Fix bug when hggroup used with primitive graphic object (bug #42532).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 hax = hax(1); |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
134 endif |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
135 |
17566
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
136 ## Position argument may alse be in PROP/VAL pair |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
137 idx = find (strcmpi (varargin, "position"), 1); |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
138 if (idx) |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
139 pos = varargin{idx+1}; |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
140 varargin(idx:idx+1) = []; |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
141 else |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
142 pos = [x(:), y(:), z(:)]; |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
143 endif |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
144 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
145 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
|
146 htmp = zeros (nt, 1); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
147 if (nx == 1) |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
148 htmp = __go_text__ (hax, "string", string{1}, |
17566
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
149 ## varargin first, in case "Units" set for pos. |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
150 varargin{:}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
151 "position", pos); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
152 elseif (nx == nt) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
153 for n = 1:nt |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
154 htmp(n) = __go_text__ (hax, "string", string{n}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
155 varargin{:}, |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
156 "position", pos(n,:)); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
157 endfor |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
158 __request_drawnow__ (); |
6405 | 159 else |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
160 error ("text: dimension mismatch for coordinates and STRING"); |
6405 | 161 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
162 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
|
163 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
|
164 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
165 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
|
166 endif |
6257 | 167 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
168 if (nargout > 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
169 h = htmp; |
6257 | 170 endif |
171 | |
172 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
173 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
174 |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
175 %!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
|
176 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
177 %! ha = {'left', 'center', 'right'}; |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
178 %! 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
|
179 %! 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
|
180 %! y = x; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
181 %! 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
|
182 %! 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
|
183 %! 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
|
184 %! 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
|
185 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
186 %! 'horizontalalignment', ha{nh}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
187 %! 'verticalalignment', va{nv}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
188 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
189 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
190 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
191 %! 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
|
192 %! 'xticklabel', ha, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
193 %! '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
|
194 %! '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
|
195 %! 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
|
196 %! xlabel ('horizontal alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
197 %! ylabel ('vertical alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
198 %! 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
|
199 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
200 %!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
|
201 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
202 %! 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
|
203 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
204 %! 'facealpha', 0); |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
205 %! 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
|
206 %! 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
|
207 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
208 %! 'horizontalalignment', 'left', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
209 %! 'verticalalignment', 'bottom'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
210 %! end |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
211 %! caxis ([-100 100]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
212 %! 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
|
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; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
216 %! 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
|
217 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
218 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
219 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
220 %! text (4, 4, {'Hello', 'World'}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
221 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
222 %! '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
|
223 %! 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
|
224 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
225 %!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
|
226 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
227 %! 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
|
228 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
229 %! 'facealpha', 0); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
230 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
231 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
232 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
233 %! zlabel (['1st zlabel';'2nd zlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
234 %! 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
|
235 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
236 %! '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
|
237 %! hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
238 %! 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
|
239 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
240 %!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
|
241 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
242 %! 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
|
243 %! 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
|
244 %! 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
|
245 %! 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
|
246 %! 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
|
247 %! 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
|
248 %! 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
|
249 %! set (h, 'string', 1:3); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
250 %! 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
|
251 %! 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
|
252 %! 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
|
253 %! 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
|
254 %! 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
|
255 %! 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
|
256 %! 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
|
257 %! 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
|
258 %! 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
|
259 %! 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
|
260 %! 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
|
261 %! 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
|
262 %! 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
|
263 %! 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
|
264 %! 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
|
265 %! 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
|
266 %! 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
|
267 %! 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
|
268 %! 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
|
269 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
270 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
271 %! 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
|
272 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
273 %! ## 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
|
274 %! 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
|
275 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
276 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
277 %! 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
|
278 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
279 %! ## Single object with multiple lines |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
280 %! 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
|
281 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
282 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
283 %! 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
|
284 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
285 %! ## 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
|
286 %! 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
|
287 %! 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
|
288 %! 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
|
289 %! 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
|
290 %! 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
|
291 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
292 %! ## 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
|
293 %! 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
|
294 %! 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
|
295 %! 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
|
296 %! 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
|
297 %! 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
|
298 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
299 %! ### 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
|
300 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
301 %! ## 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
|
302 %! 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
|
303 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
304 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
305 %! 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
|
306 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
307 %! ## 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
|
308 %! 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
|
309 %! "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
|
310 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
311 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
312 %! 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
|
313 %! "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
|
314 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
315 %! ## 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
|
316 %! 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
|
317 %! 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
|
318 %! 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
|
319 %! ## 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
|
320 %! 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
|
321 %! 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
|
322 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
323 %! ## 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
|
324 %! 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
|
325 %! ## 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
|
326 %! 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
|
327 %! 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
|
328 %! 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
|
329 %! 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
|
330 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
331 %! ## Test special keyword processing |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
332 %! 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
|
333 %! 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
|
334 %! 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
|
335 %! 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
|
336 %! |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
337 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
338 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
339 %! 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
|
340 |