Mercurial > hg > octave-lyh
annotate scripts/plot/text.m @ 17039:854cfc72c64f
patch.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/patch.m: Update to use new __plt_get_axis_arg__.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 22 Jul 2013 23:08:14 +0200 |
parents | 100a7bd2590e |
children | 1b549a0c3ca4 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 2007-2012 John W. Eaton |
6257 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6257 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6257 | 18 |
19 ## -*- texinfo -*- | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
20 ## @deftypefn {Function File} {} text (@var{x}, @var{y}, @var{label}) |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
21 ## @deftypefnx {Function File} {} text (@var{x}, @var{y}, @var{z}, @var{label}) |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
22 ## @deftypefnx {Function File} {} text (@var{x}, @var{y}, @var{label}, @var{p1}, @var{v1}, @dots{}) |
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} {} text (@var{x}, @var{y}, @var{z}, @var{label}, @var{p1}, @var{v1}, @dots{}) |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
24 ## @deftypefnx {Function File} {@var{h} =} text (@dots{}) |
6257 | 25 ## Create a text object with text @var{label} at position @var{x}, |
6895 | 26 ## @var{y}, @var{z} on the current axes. Property-value pairs following |
27 ## @var{label} may be used to specify the appearance of the text. | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
28 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
29 ## The optional return value @var{h} is a graphics handle to the created text |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
30 ## object. |
6257 | 31 ## @end deftypefn |
32 | |
33 ## Author: jwe | |
34 | |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
35 ## 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
|
36 ## 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
|
37 |
6257 | 38 function h = text (varargin) |
39 | |
6405 | 40 nargs = nargin; |
41 offset = 0; | |
42 | |
43 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) | |
44 x = varargin{1}; | |
45 y = varargin{2}; | |
6257 | 46 |
47 if (nargin > 3 && isnumeric (varargin{3})) | |
48 z = varargin{3}; | |
49 offset = 4; | |
50 else | |
51 z = zeros (size (x)); | |
52 offset = 3; | |
53 endif | |
54 | |
55 label = 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
|
56 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
|
57 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
58 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
|
59 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
|
60 nz = numel (z); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
61 if (ischar (label)) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
62 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
63 do_keyword_repl = true; |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
64 nt = rows (label); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
65 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
|
66 ## Single text object with one line |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
67 label = {label}; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
68 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
|
69 ## 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
|
70 ## 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
|
71 ## 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
|
72 ## 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
|
73 do_keyword_repl = false; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
74 label = {label}; |
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
|
75 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
|
76 ## Mutiple text objects with different strings |
10549 | 77 label = cellstr (label); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
78 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
79 ## Mutiple text objects with same 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
|
80 label = repmat ({label}, [nx, 1]); |
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 nt = nx; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
82 endif |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
83 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
84 ## Escape special keywords |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
85 if (do_keyword_repl) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
86 label = regexprep (label, '^(default|factory)$', '\\$1'); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
87 endif |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
88 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
89 elseif (iscell (label)) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
90 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
91 nt = numel (label); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
92 if (nx == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
93 ## Single text object with one or more lines |
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
|
94 label = {label}; |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
95 nt = 1; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
96 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
|
97 ## 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
|
98 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
99 ## Mutiple text objects with same string |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
100 label = repmat ({label}, [nx, 1]); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
101 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
|
102 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
103 |
6257 | 104 else |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
105 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
106 error ("text: LABEL must be a character string or cell array of character strings"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
107 |
6257 | 108 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
109 else # Only PROP/VALUE pairs |
6405 | 110 x = y = z = 0; |
111 nx = ny = nz = 1; | |
112 label = {""}; | |
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
|
113 nt = 1; |
6405 | 114 endif |
6257 | 115 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
116 ## 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
|
117 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
|
118 print_usage (); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
119 endif |
6405 | 120 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
121 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
|
122 pos = [x(:), y(:), z(:)]; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
123 ca = gca (); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
124 htmp = zeros (nt, 1); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
125 if (nx == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
126 htmp = __go_text__ (ca, "string", label{1}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
127 varargin{:}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
128 "position", pos); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
129 elseif (nx == nt) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
130 for n = 1:nt |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
131 htmp(n) = __go_text__ (ca, "string", label{n}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
132 varargin{:}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
133 "position", pos(n,:)); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
134 endfor |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
135 __request_drawnow__ (); |
6405 | 136 else |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
137 error ("text: dimension mismatch for coordinates and LABEL"); |
6405 | 138 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
139 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
|
140 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
|
141 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
142 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
|
143 endif |
6257 | 144 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
145 if (nargout > 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
146 h = htmp; |
6257 | 147 endif |
148 | |
149 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
150 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
151 |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
152 %!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
|
153 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
154 %! ha = {'left', 'center', 'right'}; |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
155 %! 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
|
156 %! 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
|
157 %! y = x; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
158 %! 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
|
159 %! 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
|
160 %! 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
|
161 %! 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
|
162 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
163 %! 'horizontalalignment', ha{nh}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
164 %! 'verticalalignment', va{nv}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
165 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
166 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
167 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
168 %! 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
|
169 %! 'xticklabel', ha, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
170 %! '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
|
171 %! '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
|
172 %! 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
|
173 %! xlabel ('horizontal alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
174 %! ylabel ('vertical alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
175 %! 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
|
176 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
177 %!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
|
178 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
179 %! 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
|
180 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
181 %! 'facealpha', 0); |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
182 %! 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
|
183 %! 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
|
184 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
185 %! 'horizontalalignment', 'left', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
186 %! 'verticalalignment', 'bottom'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
187 %! end |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
188 %! caxis ([-100 100]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
189 %! 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
|
190 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
191 %!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
|
192 %! clf; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
193 %! 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
|
194 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
195 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
196 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
197 %! text (4, 4, {'Hello', 'World'}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
198 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
199 %! '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
|
200 %! 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
|
201 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
202 %!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
|
203 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
204 %! 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
|
205 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
206 %! 'facealpha', 0); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
207 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
208 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
209 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
210 %! zlabel (['1st zlabel';'2nd zlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
211 %! 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
|
212 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
213 %! '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
|
214 %! hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
215 %! 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
|
216 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
217 %!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
|
218 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
219 %! 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
|
220 %! 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
|
221 %! 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
|
222 %! 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
|
223 %! 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
|
224 %! 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
|
225 %! 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
|
226 %! set (h, 'string', 1:3); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
227 %! 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
|
228 %! 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
|
229 %! 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
|
230 %! 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
|
231 %! 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
|
232 %! 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
|
233 %! 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
|
234 %! 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
|
235 %! 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
|
236 %! 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
|
237 %! 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
|
238 %! 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
|
239 %! 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
|
240 %! 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
|
241 %! 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
|
242 %! 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
|
243 %! 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
|
244 %! 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
|
245 %! 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
|
246 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
247 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
248 %! 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
|
249 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
250 %! ## 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
|
251 %! 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
|
252 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
253 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
254 %! 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
|
255 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
256 %! ## Single object with multiple lines |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
257 %! 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
|
258 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
259 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
260 %! 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
|
261 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
262 %! ## 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
|
263 %! 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
|
264 %! 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
|
265 %! 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
|
266 %! 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
|
267 %! 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
|
268 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
269 %! ## 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
|
270 %! 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
|
271 %! 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
|
272 %! 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
|
273 %! 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
|
274 %! 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
|
275 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
276 %! ### 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
|
277 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
278 %! ## 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
|
279 %! 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
|
280 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
281 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
282 %! 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
|
283 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
284 %! ## 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
|
285 %! 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
|
286 %! "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
|
287 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
288 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
289 %! 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
|
290 %! "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
|
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 single line |
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.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
|
294 %! 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
|
295 %! 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
|
296 %! ## 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
|
297 %! 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
|
298 %! 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
|
299 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
300 %! ## 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
|
301 %! 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
|
302 %! ## 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
|
303 %! 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
|
304 %! 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
|
305 %! 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
|
306 %! 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
|
307 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
308 %! ## Test special keyword processing |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
309 %! 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
|
310 %! 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
|
311 %! 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
|
312 %! 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
|
313 %! |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
314 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
315 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
316 %! 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
|
317 |