Mercurial > hg > octave-nkf
annotate scripts/plot/text.m @ 13136:79b9a7669bb8
Tests added for scripts/plot
(plot/ishghandle.m, plot/text.m, plot/title.m, plot/xlabel.m, plot/ylabel.m,
plot/zlabel.m): Tests added for plot functions.
plot/whitebg.m: Fix typo. Change colors only for figure under test
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Wed, 14 Sep 2011 21:03:39 +0200 |
parents | e65d1488ff6a |
children | 52c5799130c2 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 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 -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{label}) |
6257 | 21 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label}) |
6895 | 22 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{label}, @var{p1}, @var{v1}, @dots{}) |
23 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label}, @var{p1}, @var{v1}, @dots{}) | |
6257 | 24 ## Create a text object with text @var{label} at position @var{x}, |
6895 | 25 ## @var{y}, @var{z} on the current axes. Property-value pairs following |
26 ## @var{label} may be used to specify the appearance of the text. | |
6257 | 27 ## @end deftypefn |
28 | |
29 ## Author: jwe | |
30 | |
31 function h = text (varargin) | |
32 | |
6405 | 33 nargs = nargin; |
34 offset = 0; | |
35 | |
36 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) | |
37 x = varargin{1}; | |
38 y = varargin{2}; | |
39 offset = 3; | |
6257 | 40 |
41 if (nargin > 3 && isnumeric (varargin{3})) | |
42 z = varargin{3}; | |
43 offset = 4; | |
44 else | |
45 z = zeros (size (x)); | |
46 offset = 3; | |
47 endif | |
48 | |
49 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
|
50 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
|
51 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
52 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
|
53 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
|
54 nz = numel (z); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
55 if (ischar (label) || isnumeric (label)) |
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 nt = size (label, 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
|
57 if (nx > 1 && nt == 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
|
58 ## Mutiple text objects with same string |
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 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
|
60 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
|
61 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
|
62 ## Mutiple text objects with different strings |
10549 | 63 label = cellstr (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
|
64 elseif (ischar (label)) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
65 ## Single text object with one or more lines |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
66 label = {label}; |
6257 | 67 endif |
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
|
68 elseif (iscell (label)) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
69 nt = numel (label); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
70 if (nx > 1 && nt == 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
|
71 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
|
72 nt = nx; |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
73 elseif (! (nx > 1 && 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
|
74 label = {label}; |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
75 nt = 1; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
76 endif |
6257 | 77 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11424
diff
changeset
|
78 error ("text: expecting LABEL to be a character string or cell array of character strings"); |
6257 | 79 endif |
6405 | 80 else |
81 x = y = z = 0; | |
82 nx = ny = nz = 1; | |
83 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
|
84 nt = 1; |
6405 | 85 endif |
6257 | 86 |
6405 | 87 if (rem (numel (varargin), 2) == 0) |
88 | |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
89 if (nx == ny && nx == nz && (nt == nx || nt == 1 || nx == 1)) |
6405 | 90 pos = [x(:), y(:), z(:)]; |
91 ca = gca (); | |
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
|
92 tmp = zeros (nt, 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
|
93 if (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
|
94 ## TODO - Modify __go_text__() to accept cell-strings |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
95 tmp = __go_text__ (ca, "string", "foobar", |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
96 varargin{:}, |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
97 "position", pos); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
98 set (tmp, "string", label{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
|
99 elseif (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
|
100 for n = 1:nt |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
101 tmp(n) = __go_text__ (ca, "string", label{n}, |
11272
521f2bb7c443
text.m: Ensure text position property is set after units property.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
102 varargin{:}, |
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
|
103 "position", pos(n,:)); |
10549 | 104 endfor |
105 __request_drawnow__ (); | |
6405 | 106 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11424
diff
changeset
|
107 error ("text: dimension mismatch for coordinates and LABEL"); |
6405 | 108 endif |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
109 elseif (nt == nx || nt == 1 || nx == 1) |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
110 error ("text: dimension mismatch for coordinates"); |
6405 | 111 else |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
112 error ("text: mismatch betwween coordinates and strings"); |
6405 | 113 endif |
6257 | 114 |
115 if (nargout > 0) | |
116 h = tmp; | |
117 endif | |
118 | |
119 else | |
120 print_usage (); | |
121 endif | |
122 | |
123 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
124 |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
125 %!demo |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
126 %! clf |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
127 %! ha = {"left", "center", "right"}; |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
128 %! va = {"bottom", "middle", "top"}; |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
129 %! x = [0.25 0.5 0.75]; |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
130 %! y = [0.25 0.5 0.75]; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
131 %! for t = 0:30:359; |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
132 %! for nh = 1:numel(ha) |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
133 %! for nv = 1:numel(va) |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
134 %! text (x(nh), y(nv), "Hello World", ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
135 %! "rotation", t, ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
136 %! "horizontalalignment", ha{nh}, ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
137 %! "verticalalignment", va{nv}) |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
138 %! endfor |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
139 %! endfor |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
140 %! endfor |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
141 %! set (gca, "xtick", [0.25, 0.5, 0.75], ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
142 %! "xticklabel", ha, ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
143 %! "ytick", [0.25, 0.5, 0.75], ... |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
144 %! "yticklabel", va) |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
145 %! axis ([0 1 0 1]) |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
146 %! xlabel ("horizontal alignment") |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
147 %! ylabel ("vertical alignment") |
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
148 %! 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
|
149 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
150 %!demo |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
151 %! clf |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
152 %! h = mesh (peaks, "edgecolor", 0.7 * [1 1 1], ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
153 %! "facecolor", "none", ... |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
154 %! "facealpha", 0); |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
155 %! for t = 0:45:359; |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
156 %! text (25, 25, 0, "Vertical Alignment = Bottom", ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
157 %! "rotation", t, ... |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
158 %! "horizontalalignment", "left", ... |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
159 %! "verticalalignment", "bottom") |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
160 %! endfor |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
161 %! caxis ([-100 100]) |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
162 %! 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
|
163 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
164 %!demo |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
165 %! clf |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
166 %! axis ([0 8 0 8]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
167 %! title (["First title";"Second title"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
168 %! xlabel (["First xlabel";"Second xlabel"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
169 %! ylabel (["First ylabel";"Second ylabel"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
170 %! text (4, 4, {"Hello", "World"}, ... |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
171 %! "horizontalalignment", "center", ... |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
172 %! "verticalalignment", "middle") |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
173 %! grid on |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
174 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
175 %!demo |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
176 %! clf |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
177 %! h = mesh (peaks, "edgecolor", 0.7 * [1 1 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
|
178 %! "facecolor", "none", ... |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
179 %! "facealpha", 0); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
180 %! title (["First title";"Second title"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
181 %! xlabel (["First xlabel";"Second xlabel"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
182 %! ylabel (["First ylabel";"Second ylabel"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
183 %! zlabel (["First zlabel";"Second zlabel"]) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
184 %! text (0, 0, 5, {"Hello", "World"}, ... |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
185 %! "horizontalalignment", "center", ... |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
186 %! "verticalalignment", "middle") |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
187 %! hold on |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
188 %! plot3 (0, 0, 5, "+k") |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
189 %! |
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 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
192 %! clf |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
193 %! h = text (0.5, 0.3, "char"); |
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
|
194 %! assert ("char", class (get (h, "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
195 %! h = text (0.5, 0.4, ["char row 1"; "char row 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
|
196 %! assert ("char", class (get (h, "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
197 %! h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; "cell2str (2,1)", "cell2str (2,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
|
198 %! assert ("cell", class (get (h, "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
199 %! h = text (0.5, 0.8, "foobar"); |
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
|
200 %! set (h, "string", 1:3) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
201 %! h = text ([0.1, 0.1], [0.3, 0.4], "one string & two objects"); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
202 %! assert ("char", class (get (h(1), "string"))) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
203 %! assert ("char", class (get (h(2), "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
204 %! h = text ([0.1, 0.1], [0.5, 0.6], {"one cellstr & two objects"}); |
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
|
205 %! assert ("cell", class (get (h(1), "string"))) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
206 %! assert ("cell", class (get (h(2), "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
207 %! h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr 1 object 1", "cellstr 2 object 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
|
208 %! assert ("char", class (get (h(1), "string"))) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
209 %! assert ("char", class (get (h(2), "string"))) |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
210 %! h = text ([0.1, 0.1], [0.1, 0.2], ["1st string & 1st object"; "2nd string & 2nd object"]); |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
211 %! assert ("char", class (get (h(1), "string"))) |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
212 %! assert ("char", class (get (h(2), "string"))) |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
213 %! h = text (0.7, 0.6, "single string"); |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
214 %! assert ("char", class (get (h, "string"))) |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
215 %! h = text (0.7, 0.5, {"single cell-string"}); |
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
216 %! assert ("cell", class (get (h, "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
|
217 %! xlabel (1:2) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
218 %! ylabel (1:2) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
219 %! title (1:2) |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
220 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
221 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
222 %! hf = figure ("visible", "off"); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
223 %! unwind_protect |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
224 %! h = text (0.5, 0.3, "char"); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
225 %! assert ("char", class (get (h, "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
226 %! h = text (0.5, 0.4, ["char row 1"; "char row 2"]); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
227 %! assert ("char", class (get (h, "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
228 %! h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; "cell2str (2,1)", "cell2str (2,2)"}); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
229 %! assert ("cell", class (get (h, "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
230 %! h = text (0.5, 0.8, "foobar"); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
231 %! set (h, "string", 1:3) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
232 %! h = text ([0.1, 0.1], [0.3, 0.4], "one string & two objects"); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
233 %! assert ("char", class (get (h(1), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
234 %! assert ("char", class (get (h(2), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
235 %! h = text ([0.1, 0.1], [0.5, 0.6], {"one cellstr & two objects"}); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
236 %! assert ("cell", class (get (h(1), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
237 %! assert ("cell", class (get (h(2), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
238 %! h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr 1 object 1", "cellstr 2 object 2"}); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
239 %! assert ("char", class (get (h(1), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
240 %! assert ("char", class (get (h(2), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
241 %! h = text ([0.1, 0.1], [0.1, 0.2], ["1st string & 1st object"; "2nd string & 2nd object"]); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
242 %! assert ("char", class (get (h(1), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
243 %! assert ("char", class (get (h(2), "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
244 %! h = text (0.7, 0.6, "single string"); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
245 %! assert ("char", class (get (h, "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
246 %! h = text (0.7, 0.5, {"single cell-string"}); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
247 %! assert ("cell", class (get (h, "string"))) |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
248 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
249 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
250 %! end_unwind_protect |