annotate scripts/plot/text.m @ 12965:22bc9ec80c2c

allow multi-line string property for text objects using cell arrays or char matrices * __axis_label__.m: Don't check type of txt argument. * __go_draw_axes__.m: Handle multi-line string property for text objects. * text.m: Likewise. * gl2ps-renderer.cc (glps_renderer::draw_text): Handle text::properties string property as octave_value object that can contain either a char array or cellstr object. * graphics.cc (axes::properties::update_xlabel_position, axes::properties::update_ylabel_position, axes::properties::update_zlabel_position, axes::properties::get_extent, text::properties::update_text_extent): Likewise. * graphics.h.in (text_label_property::do_set): Don't forget to set stored_type when value is a cell. (text::properties::get_string): Delete custom getter.
author Ben Abbott <bpabbott@mac.com>
date Mon, 15 Aug 2011 10:24:09 -0400
parents a754c2d8a13f
children e65d1488ff6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11472
diff changeset
1 ## Copyright (C) 2007-2011 John W. Eaton
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
2 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
4 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
9 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
14 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
18
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
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
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6419
diff changeset
22 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{label}, @var{p1}, @var{v1}, @dots{})
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6419
diff changeset
23 ## @deftypefnx {Function File} {@var{h} =} text (@var{x}, @var{y}, @var{z}, @var{label}, @var{p1}, @var{v1}, @dots{})
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
24 ## Create a text object with text @var{label} at position @var{x},
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6419
diff changeset
25 ## @var{y}, @var{z} on the current axes. Property-value pairs following
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6419
diff changeset
26 ## @var{label} may be used to specify the appearance of the text.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
27 ## @end deftypefn
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
28
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
29 ## Author: jwe
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
30
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
31 function h = text (varargin)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
32
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
33 nargs = nargin;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
34 offset = 0;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
35
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
36 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
37 x = varargin{1};
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
38 y = varargin{2};
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
39 offset = 3;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
40
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
41 if (nargin > 3 && isnumeric (varargin{3}))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
42 z = varargin{3};
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
43 offset = 4;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
44 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
45 z = zeros (size (x));
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
46 offset = 3;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
47 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
48
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
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
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7016
diff changeset
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
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
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;
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
73 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
74 else
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 label = {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
76 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
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
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
79 endif
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
80 else
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
81 x = y = z = 0;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
82 nx = ny = nz = 1;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
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
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
85 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
86
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
87 if (rem (numel (varargin), 2) == 0)
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
88
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
89 if (nx == ny && nx == nz)
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
90 pos = [x(:), y(:), z(:)];
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
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
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7016
diff changeset
104 endfor
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7016
diff changeset
105 __request_drawnow__ ();
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
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
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
108 endif
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
109 else
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
110 error ("text: dimension mismatch for coordinates");
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
111 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
112
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
113 if (nargout > 0)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
114 h = tmp;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
115 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
116
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
117 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
118 print_usage ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
119 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
120
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
121 endfunction
11416
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
122
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
123 %!demo
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
124 %! clf
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
125 %! ha = {"left", "center", "right"};
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
126 %! 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
127 %! 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
128 %! 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
129 %! for t = 0:30:359;
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
130 %! for nh = 1:numel(ha)
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
131 %! 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
132 %! 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
133 %! "rotation", t, ...
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
134 %! "horizontalalignment", ha{nh}, ...
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
135 %! "verticalalignment", va{nv})
11416
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
136 %! endfor
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
137 %! endfor
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
138 %! endfor
12437
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
139 %! 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
140 %! "xticklabel", ha, ...
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
141 %! "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
142 %! "yticklabel", va)
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
143 %! axis ([0 1 0 1])
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
144 %! xlabel ("horizontal alignment")
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
145 %! ylabel ("vertical alignment")
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
146 %! 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
147
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
148 %!demo
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
149 %! clf
12437
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
150 %! 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
151 %! "facecolor", "none", ...
11424
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
152 %! "facealpha", 0);
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
153 %! 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
154 %! 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
155 %! "rotation", t, ...
a754c2d8a13f Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents: 11523
diff changeset
156 %! "horizontalalignment", "left", ...
11424
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
157 %! "verticalalignment", "bottom")
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
158 %! endfor
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
159 %! caxis ([-100 100])
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
160 %! 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
161
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
162 %!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
163 %! 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
164 %! 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
165 %! 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
166 %! 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
167 %! 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
168 %! 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
169 %! "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
170 %! "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
171 %! 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
172
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 %!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
174 %! 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
175 %! 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
176 %! "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
177 %! "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
178 %! 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
179 %! 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
180 %! 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
181 %! 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
182 %! 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
183 %! "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
184 %! "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
185 %! 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
186 %! 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
187 %!
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
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 %!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
190 %! 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
191 %! h = text (0.6, 0.3, "char");
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 %! assert ("char", class (get (h, "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
193 %! h = text (0.6, 0.4, ["char row 1"; "char row 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
194 %! assert ("char", class (get (h, "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
195 %! h = text (0.6, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; "cell2str (2,1)", "cell2str (2,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
196 %! assert ("cell", class (get (h, "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
197 %! h = text (0.6, 0.8, "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
198 %! set (h, "string", 1:3)
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
199 %! h = text ([0.2, 0.2], [0.3, 0.4], "one string & two objects");
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 %! 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
201 %! assert ("char", class (get (h(2), "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
202 %! h = text ([0.2, 0.2], [0.5, 0.6], {"one cellstr & two objects"});
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 ("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
204 %! assert ("cell", class (get (h(2), "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
205 %! h = text ([0.2, 0.2], [0.7, 0.8], {"cellstr 1 object 1", "cellstr 2 object 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
206 %! 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
207 %! assert ("char", class (get (h(2), "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
208 %! 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
209 %! 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
210 %! 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
211