Mercurial > octave
annotate scripts/plot/appearance/text.m @ 28093:05c1217d0dae stable
doc: Create better looking cross references in Info format (bug #57845).
* image.m, text.m, light.m, line.m, patch.m, surface.m, axes.m, figure.m:
Use 1-input form of @ref which produces better visuals in Info format.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 18 Feb 2020 08:15:39 -0800 |
parents | b09432b20a84 |
children | 0a5b15007766 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2007-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
6257 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24173
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
6257 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24173
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
6257 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
6257 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24173
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
6257 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20528
diff
changeset
|
27 ## @deftypefn {} {} text (@var{x}, @var{y}, @var{string}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20528
diff
changeset
|
28 ## @deftypefnx {} {} text (@var{x}, @var{y}, @var{z}, @var{string}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20528
diff
changeset
|
29 ## @deftypefnx {} {} text (@dots{}, @var{prop}, @var{val}, @dots{}) |
27227
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
30 ## @deftypefnx {} {} text (@var{hax}, @dots{}) |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20528
diff
changeset
|
31 ## @deftypefnx {} {@var{h} =} text (@dots{}) |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
32 ## 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
|
33 ## (@var{z}) on the current axes. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
34 ## |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
35 ## 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
|
36 ## 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
|
37 ## 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
|
38 ## |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
39 ## 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
|
40 ## text. |
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
41 ## |
27227
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
42 ## If the first argument @var{hax} is an axes handle, then add text to this |
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
43 ## axes, rather than the current axes returned by @code{gca}. |
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
44 ## |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
45 ## 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
|
46 ## created text objects. |
24551
a7b6502b5cb5
doc: Add @ref from graphic object creation functions to list of graphic properties (bug #52816).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
47 ## |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
48 ## Example 1 : multi-line text via 3 different methods |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
49 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
50 ## @example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
51 ## @group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
52 ## text (0.5, 0.8, @{"Line 1", "Line 2"@}) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
53 ## text (0.5, 0.6, ["Line 1"; "Line 2"]) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
54 ## text (0.5, 0.4, "Line 1\nLine 2") |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
55 ## @end group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
56 ## @end example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
57 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
58 ## Example 2 : text at multiple locations |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
59 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
60 ## @example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
61 ## @group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
62 ## text ([0.2, 0.2], [0.8, 0.6], "Same text at two locations") |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
63 ## text ([0.4, 0.4], [0.8, 0.6], @{"Point 1 Text", "Point 2 text"@}) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
64 ## text ([0.6, 0.6], [0.8, 0.6], @{@{"Point 1 Line 1", "Point 1 Line 2@}, |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
65 ## "Point 2 text"@}) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
66 ## @end group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
67 ## @end example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
68 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
69 ## Example 2 : adjust appearance using text properties |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
70 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
71 ## @example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
72 ## @group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
73 ## ht = text (0.5, 0.5, "Hello World", "fontsize", 20); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
74 ## set (ht, "color", "red"); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
75 ## @end group |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
76 ## @end example |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
77 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
78 ## Programming Notes: The full list of properties is documented at |
28093
05c1217d0dae
doc: Create better looking cross references in Info format (bug #57845).
Rik <rik@octave.org>
parents:
27984
diff
changeset
|
79 ## @ref{Text Properties}. |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
80 ## |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
81 ## Any numeric entries in a cell array will be converted to text using |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
82 ## @code{sprintf ("%g")}. For more precise control of the appearance convert |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
83 ## any numeric entries to strings using @code{num2str}, @code{sprintf}, etc., |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
84 ## before calling @code{text}. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
85 ## @seealso{gtext, title, xlabel, ylabel, zlabel} |
6257 | 86 ## @end deftypefn |
87 | |
27984
b09432b20a84
maint: Remove special cases of old version control keywords in code base.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
88 ## Caution: The following code is rigged for Matlab compatibility and is |
b09432b20a84
maint: Remove special cases of old version control keywords in code base.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
89 ## full of hidden assumptions. Be very wary when modifying. |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
90 |
6257 | 91 function h = text (varargin) |
92 | |
27227
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
93 [hax, varargin, nargin] = __plt_get_axis_arg__ ("text", varargin{:}); |
c90648dde5cf
text.m: Allow axes handle as first argument (bug #56513).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
94 |
6405 | 95 nargs = nargin; |
96 offset = 0; | |
97 | |
98 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) | |
99 x = varargin{1}; | |
100 y = varargin{2}; | |
6257 | 101 |
102 if (nargin > 3 && isnumeric (varargin{3})) | |
103 z = varargin{3}; | |
104 offset = 4; | |
105 else | |
106 z = zeros (size (x)); | |
107 offset = 3; | |
108 endif | |
109 | |
17497
96cf8ee3440e
text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
110 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
|
111 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
|
112 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
113 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
|
114 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
|
115 nz = numel (z); |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
116 if (nx != ny || nx != nz) |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
117 error ("text: number of X, Y, and Z coordinates must match"); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
118 endif |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
119 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
120 else # Only PROP/VALUE pairs |
6405 | 121 x = y = z = 0; |
122 nx = ny = nz = 1; | |
25466
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
123 string = ""; |
6405 | 124 endif |
6257 | 125 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
126 ## 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
|
127 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
|
128 print_usage (); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
129 endif |
6405 | 130 |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
131 ## String argument may be in PROP/VAL pair |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
132 idx = find (strcmpi (varargin, "string"), 1); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
133 if (idx) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
134 string = varargin{idx+1}; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
135 varargin(idx:idx+1) = []; |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
136 endif |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
137 |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
138 ## Position argument may be in PROP/VAL pair |
17566
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
139 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
|
140 if (idx) |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
141 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
|
142 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
|
143 else |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
144 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
|
145 endif |
4166048ba6cf
text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents:
17497
diff
changeset
|
146 |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
147 ## Validate string argument |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
148 if (ischar (string)) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
149 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
150 do_keyword_repl = true; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
151 nt = rows (string); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
152 if (nx == 1 && (nt == 1 || nt == 0)) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
153 ## Single text object with one line or empty line |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
154 string = {string}; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
155 nt = 1; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
156 elseif (nx == 1 && nt > 1) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
157 ## Single text object with multiple lines |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
158 ## FIXME: "default" or "factory" as first row |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
159 ## should be escaped to "\default" or "\factory" |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
160 ## Other rows do not require escaping. |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
161 do_keyword_repl = false; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
162 string = {string}; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
163 elseif (nx > 1 && nt == nx) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
164 ## Multiple text objects with different strings |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
165 string = cellstr (string); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
166 elseif (nx > 1 && nt == 1) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
167 ## Multiple text objects with same string |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
168 string = repmat ({string}, [nx, 1]); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
169 nt = nx; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
170 else |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
171 error ("text: invalid combination of points and text strings"); |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
172 endif |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
173 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
174 ## Escape special keywords |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
175 if (do_keyword_repl) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
176 string = regexprep (string, '^(default|factory)$', '\\$1'); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
177 endif |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
178 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
179 elseif (iscell (string)) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
180 |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
181 if (! iscellstr (string)) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
182 ## Matlab compatibility: convert any numeric cells to strings |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
183 string = cell2cellstr (string); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
184 endif |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
185 |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
186 nt = numel (string); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
187 if (nx == 1) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
188 ## Single text object with one or more lines |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
189 string = {string}; |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
190 nt = 1; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
191 elseif (nx > 1 && nt == nx) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
192 ## Multiple text objects with different strings |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
193 elseif (nx > 1 && nt == 1) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
194 ## Multiple text objects with same string |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
195 string = repmat ({cellstr(string)}, [nx, 1]); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
196 nt = nx; |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
197 else |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
198 error ("text: invalid combination of points and text strings"); |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
199 endif |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
200 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
201 else |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
202 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
203 error ("text: STRING must be a character string or cell array of character strings"); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
204 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
205 endif |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
206 |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
207 ## Select the correct axes |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
208 if (isempty (hax)) |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
209 hax = gca (); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
210 else |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
211 hax = hax(1); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
212 endif |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
213 |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
214 ## Call __go_text__ to do the work |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
215 htmp = zeros (nt, 1); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
216 if (nx == 1) |
23915
adf580507691
Fix error from TeX parser when 'interpreter' is set to 'none' (bug #51751).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
217 ## Set varargin first, in case it changes units or interpreter properties. |
adf580507691
Fix error from TeX parser when 'interpreter' is set to 'none' (bug #51751).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
218 htmp = __go_text__ (hax, varargin{:}, "position", pos, |
adf580507691
Fix error from TeX parser when 'interpreter' is set to 'none' (bug #51751).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
219 "string", string{1}); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
220 else |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
221 for n = 1:nt |
23915
adf580507691
Fix error from TeX parser when 'interpreter' is set to 'none' (bug #51751).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
222 htmp(n) = __go_text__ (hax, varargin{:}, "position", pos(n,:), |
adf580507691
Fix error from TeX parser when 'interpreter' is set to 'none' (bug #51751).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
223 "string", string{n}); |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
224 endfor |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
225 __request_drawnow__ (); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
226 endif |
6257 | 227 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
228 if (nargout > 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
229 h = htmp; |
6257 | 230 endif |
231 | |
232 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
233 |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
234 ## Helper function converts any numeric entries to strings |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
235 function cstr = cell2cellstr (c) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
236 cstr = c; |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
237 idx = cellfun (@isnumeric, c); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
238 cstr(idx) = cellfun (@(x) sprintf ("%g", x), c(idx), "uniformoutput", false); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
239 endfunction |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
240 |
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 |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
242 %!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
|
243 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
244 %! ha = {"left", "center", "right"}; |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
245 %! 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
|
246 %! 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
|
247 %! y = x; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
248 %! 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
|
249 %! 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
|
250 %! for nv = 1:numel (va) |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
251 %! text (x(nh), y(nv), "Hello World", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
252 %! "rotation", t, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
253 %! "horizontalalignment", ha{nh}, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
254 %! "verticalalignment", va{nv}); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
255 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
256 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
257 %! endfor |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
258 %! set (gca, "xtick", [0.25, 0.5, 0.75], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
259 %! "xticklabel", ha, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
260 %! "ytick", [0.25, 0.5, 0.75], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
261 %! "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
|
262 %! axis ([0 1 0 1]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
263 %! xlabel ("horizontal alignment"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
264 %! ylabel ("vertical alignment"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
265 %! 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
|
266 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
267 %!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
|
268 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
269 %! h = mesh (peaks, "edgecolor", 0.7 * [1 1 1], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
270 %! "facecolor", "none", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
271 %! "facealpha", 0); |
24173
730227072acb
Add support for text background area for OpenGL toolkits (bug #39692).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23915
diff
changeset
|
272 %! colors = jet (9); |
730227072acb
Add support for text background area for OpenGL toolkits (bug #39692).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23915
diff
changeset
|
273 %! ii = 1; |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
274 %! for t = 0:45:359; |
24173
730227072acb
Add support for text background area for OpenGL toolkits (bug #39692).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23915
diff
changeset
|
275 %! ii = ii +1; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
276 %! text (25, 25, 0, "Vertical Alignment = Bottom", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
277 %! "rotation", t, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
278 %! "horizontalalignment", "left", ... |
24173
730227072acb
Add support for text background area for OpenGL toolkits (bug #39692).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23915
diff
changeset
|
279 %! "backgroundcolor", colors(ii,:), ... |
730227072acb
Add support for text background area for OpenGL toolkits (bug #39692).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23915
diff
changeset
|
280 %! "edgecolor", "k", ... |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
281 %! "verticalalignment", "bottom"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
282 %! endfor |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
283 %! caxis ([-100 100]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
284 %! 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
|
285 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
286 %!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
|
287 %! clf; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
288 %! axis ([0 8 0 8]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
289 %! title (["1st title";"2nd title"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
290 %! xlabel (["1st xlabel";"2nd xlabel"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
291 %! ylabel (["1st ylabel";"2nd ylabel"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
292 %! text (4, 4, {"Hello", "World"}, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
293 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
294 %! "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
|
295 %! 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
|
296 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
297 %!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
|
298 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
299 %! h = mesh (peaks (), "edgecolor", 0.7 * [1 1 1], ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
300 %! "facecolor", "none", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
301 %! "facealpha", 0); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
302 %! title (["1st title";"2nd title"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
303 %! xlabel (["1st xlabel";"2nd xlabel"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
304 %! ylabel (["1st ylabel";"2nd ylabel"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
305 %! zlabel (["1st zlabel";"2nd zlabel"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
306 %! text (0, 0, 5, {"Hello", "World"}, ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
307 %! "horizontalalignment", "center", ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
308 %! "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
|
309 %! hold on; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
310 %! 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
|
311 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
312 %!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
|
313 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
314 %! h = text (0.5, 0.3, "char"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
315 %! h = text (0.5, 0.4, ["char row 1"; "char row 2"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
316 %! h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; "cell2str (2,1)", "cell2str (2,2)"}); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
317 %! h = text (0.5, 0.8, "foobar"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
318 %! set (h, "string", 1:3); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
319 %! h = text ([0.1, 0.1], [0.3, 0.4], "one string & two objects"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
320 %! h = text ([0.1, 0.1], [0.5, 0.6], {"one cellstr & two objects"}); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
321 %! h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr 1 object 1", "cellstr 2 object 2"}); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
322 %! h = text ([0.1, 0.1], [0.1, 0.2], ["1st string & 1st object"; "2nd string & 2nd object"]); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
323 %! h = text (0.7, 0.6, "single string"); |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
22151
diff
changeset
|
324 %! h = text (0.7, 0.5, {"single cell-string"}); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
325 %! 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
|
326 %! 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
|
327 %! 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
|
328 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
329 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
330 %! 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
|
331 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
332 %! ## Single object with one line |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
333 %! h = text (0.5, 0.5, "single object with one line"); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
334 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
335 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
336 %! 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
|
337 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
338 %! ## Single object with multiple lines |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
339 %! h = text (0.5, 0.3, ["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
|
340 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
341 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
342 %! 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
|
343 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
344 %! ## 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
|
345 %! 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
|
346 %! 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
|
347 %! 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
|
348 %! 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
|
349 %! 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
|
350 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
351 %! ## Multiple objects with multiple lines |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
352 %! h = text ([0.7, 0.7], [0.3, 0.4], ["string1"; "string2"]); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
353 %! 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
|
354 %! 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
|
355 %! 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
|
356 %! 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
|
357 %! |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
358 %! ## Test special keyword processing |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
359 %! h = text (0.5, 0.5, "default"); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
360 %! assert (get (h, "string"), "default"); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
361 %! h = text (0.5, 0.5, "factory"); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
362 %! assert (get (h, "string"), "factory"); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
363 %! |
21937
55f7de37b618
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
21760
diff
changeset
|
364 %! ## Test special null ("") string |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
365 %! h = text (0.5, 0.5, ""); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
366 %! assert (get (h, "string"), ""); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
367 %! |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
368 %! unwind_protect_cleanup |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
369 %! close (hf); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
370 %! end_unwind_protect |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
371 |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
372 ## Tests repeated with cell input ## |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
373 %!test |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
374 %! hf = figure ("visible", "off"); |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
375 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
376 %! ## Single object with one line |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
377 %! h = text (0.5, 0.5, {"single object with one line"}); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
378 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
379 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
380 %! 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
|
381 %! |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
382 %! # Single object with multiple lines |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
383 %! h = text (0.5, 0.3, {"cell2str (1,1)", "cell2str (1,2)"; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
384 %! "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
|
385 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
386 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
387 %! 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
|
388 %! "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
|
389 %! |
20526
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
390 %! ## Single object with multiple lines including empty cell |
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
391 %! h = text (0.5, 0.9, {"Line1"; []; "Line3"}); |
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
392 %! obs = get (h, "string"); |
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
393 %! assert (class (obs), "cell"); |
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
394 %! assert (obs, {"Line1"; ""; "Line3"}); |
ecca28364445
text.m: Allow '[]' to indicate blank line in multi-line cellstrings (bug #43017).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
395 %! |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
396 %! ## 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
|
397 %! 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
|
398 %! 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
|
399 %! 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
|
400 %! 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
|
401 %! 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
|
402 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
403 %! ## 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
|
404 %! 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
|
405 %! 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
|
406 %! 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
|
407 %! 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
|
408 %! 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
|
409 %! |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
410 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
411 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
412 %! 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
|
413 |
25458
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
414 %!test <*54067> |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
415 %! hf = figure ("visible", "off"); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
416 %! unwind_protect |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
417 %! ht = text ("String", "Hello", "Position", [0.5, 0.5], "FontSize", 16); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
418 %! assert (get (ht, "String"), "Hello"); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
419 %! assert (get (ht, "FontSize"), 16); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
420 %! unwind_protect_cleanup |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
421 %! close (hf); |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
422 %! end_unwind_protect |
1580ceab7f2c
text.m: Fix regression when 'String' property is specified (bug #54067).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
423 |
25466
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
424 %!test <*54109> |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
425 %! hf = figure ("visible", "off"); |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
426 %! unwind_protect |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
427 %! ht = text (); |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
428 %! assert (get (ht, "string"), ""); |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
429 %! unwind_protect_cleanup |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
430 %! close (hf); |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
431 %! end_unwind_protect |
f09f7c7815e3
fix regression in text (bug #54109)
John W. Eaton <jwe@octave.org>
parents:
25458
diff
changeset
|
432 |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
433 %!test <*56395> |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
434 %! hf = figure ("visible", "off"); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
435 %! unwind_protect |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
436 %! ht = text (.3, .8, {"Hello", 'world', [], 1e7}); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
437 %! assert (get (ht, "string"), {"Hello"; "world"; ""; "1e+07"}); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
438 %! unwind_protect_cleanup |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
439 %! close (hf); |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
440 %! end_unwind_protect |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
441 |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
442 ## Test input validation |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
443 %!error <X, Y, and Z coordinates must match> text (1, [2 3], "foobar") |
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
444 %!error <X, Y, and Z coordinates must match> text (1, 2, [3 4], "foobar") |
27299
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
445 %!error <Invalid call to text> text (1,2, "text", "opt1") |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
446 %!error <invalid combination> text ([1 2], [3, 4], ['a'; 'b'; 'c']) |
6ec7b2e73b5b
text.m: Convert any numeric inputs to strings with sprintf for ML compatibility (bug #56395).
Rik <rik@octave.org>
parents:
27227
diff
changeset
|
447 %!error <invalid combination> text ([1 2], [3, 4], {'a', 'b', 'c'}) |
21760
31b4b614ed55
text.m: Improve matlab compatibility (bug #47904)
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
448 %!error <STRING must be a character string> text (1, 2, 3) |