Mercurial > hg > octave-nkf
annotate scripts/plot/text.m @ 17122:eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
* doc/interpreter/plot.txi: Add @findex entries that were in xlim.m
* scripts/miscellaneous/getappdata.m scripts/miscellaneous/setappdata.m,
scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m,
scripts/plot/axes.m, scripts/plot/axis.m, scripts/plot/bar.m,
scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m,
scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m,
scripts/plot/close.m, scripts/plot/closereq.m, scripts/plot/colorbar.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourc.m,
scripts/plot/contourf.m, scripts/plot/copyobj.m, scripts/plot/cylinder.m,
scripts/plot/daspect.m, scripts/plot/diffuse.m, scripts/plot/ellipsoid.m,
scripts/plot/errorbar.m, scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m,
scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezplot.m,
scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/ezsurf.m,
scripts/plot/ezsurfc.m, scripts/plot/feather.m, scripts/plot/figure.m,
scripts/plot/fill.m, scripts/plot/findall.m, scripts/plot/findobj.m,
scripts/plot/fplot.m, scripts/plot/gca.m, scripts/plot/gcbf.m,
scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m,
scripts/plot/ginput.m, scripts/plot/graphics_toolkit.m, scripts/plot/grid.m,
scripts/plot/gtext.m, scripts/plot/guidata.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hggroup.m, scripts/plot/hidden.m,
scripts/plot/hist.m, scripts/plot/hold.m, scripts/plot/ishghandle.m,
scripts/plot/ishold.m, scripts/plot/isocolors.m, scripts/plot/isprop.m,
scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/linkprop.m,
scripts/plot/loglog.m, scripts/plot/loglogerr.m, scripts/plot/mesh.m,
scripts/plot/meshc.m, scripts/plot/meshgrid.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/peaks.m,
scripts/plot/pie.m, scripts/plot/pie3.m, scripts/plot/plot.m,
scripts/plot/plot3.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/polar.m, scripts/plot/print.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/rectangle.m, scripts/plot/refresh.m,
scripts/plot/refreshdata.m, scripts/plot/ribbon.m, scripts/plot/rose.m,
scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m,
scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m,
scripts/plot/semilogyerr.m, scripts/plot/shading.m, scripts/plot/shg.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/specular.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surface.m, scripts/plot/surfc.m,
scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/text.m,
scripts/plot/title.m, scripts/plot/trimesh.m, scripts/plot/triplot.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/waitbar.m,
scripts/plot/waitforbuttonpress.m, scripts/plot/waterfall.m,
scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m,
scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m,
scripts/plot/zlim.m: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 13:53:30 -0700 |
parents | 1b549a0c3ca4 |
children | 96cf8ee3440e |
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 -*- | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
20 ## @deftypefn {Function File} {} text (@var{x}, @var{y}, @var{string}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
21 ## @deftypefnx {Function File} {} text (@var{x}, @var{y}, @var{z}, @var{string}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
22 ## @deftypefnx {Function File} {} text (@dots{}, @var{prop}, @var{val}, @dots{}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{h} =} text (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
24 ## Create a text object with text @var{string} at position @var{x}, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
25 ## @var{y}, @var{z} on the current axes. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
26 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
27 ## Optional property/value pairs following may be used to specify the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
28 ## 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
|
29 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
30 ## 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
|
31 ## object. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17041
diff
changeset
|
32 ## @seealso{gtext, title, xlabel, ylabel, zlabel} |
6257 | 33 ## @end deftypefn |
34 | |
35 ## Author: jwe | |
36 | |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
37 ## 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
|
38 ## 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
|
39 |
6257 | 40 function h = text (varargin) |
41 | |
6405 | 42 nargs = nargin; |
43 offset = 0; | |
44 | |
45 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2})) | |
46 x = varargin{1}; | |
47 y = varargin{2}; | |
6257 | 48 |
49 if (nargin > 3 && isnumeric (varargin{3})) | |
50 z = varargin{3}; | |
51 offset = 4; | |
52 else | |
53 z = zeros (size (x)); | |
54 offset = 3; | |
55 endif | |
56 | |
57 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
|
58 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
|
59 |
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 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
|
61 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
|
62 nz = numel (z); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
63 if (ischar (label)) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
64 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
65 do_keyword_repl = true; |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
66 nt = rows (label); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
67 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
|
68 ## 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
|
69 label = {label}; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
70 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
|
71 ## 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
|
72 ## 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
|
73 ## 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
|
74 ## 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
|
75 do_keyword_repl = false; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
76 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
|
77 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
|
78 ## Mutiple text objects with different strings |
10549 | 79 label = cellstr (label); |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
80 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
81 ## 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
|
82 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
|
83 nt = nx; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
84 endif |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
85 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
86 ## Escape special keywords |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
87 if (do_keyword_repl) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
88 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
|
89 endif |
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 elseif (iscell (label)) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
92 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
93 nt = numel (label); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
94 if (nx == 1) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
95 ## 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
|
96 label = {label}; |
12971
e65d1488ff6a
text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
12965
diff
changeset
|
97 nt = 1; |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
98 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
|
99 ## 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
|
100 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
101 ## 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
|
102 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
|
103 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
|
104 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
105 |
6257 | 106 else |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
107 |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
108 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
|
109 |
6257 | 110 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
111 else # Only PROP/VALUE pairs |
6405 | 112 x = y = z = 0; |
113 nx = ny = nz = 1; | |
114 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
|
115 nt = 1; |
6405 | 116 endif |
6257 | 117 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
118 ## 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
|
119 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
|
120 print_usage (); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
121 endif |
6405 | 122 |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
123 ## Get axis argument which may be in a 'parent' PROP/VAL pair |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
124 [hax, varargin] = __plt_get_axis_arg__ ("text", varargin{:}); |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
125 |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
126 if (isempty (hax)) |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
127 hax = gca (); |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
128 endif |
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
129 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
130 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
|
131 pos = [x(:), y(:), z(:)]; |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
132 htmp = zeros (nt, 1); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
133 if (nx == 1) |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
134 htmp = __go_text__ (hax, "string", label{1}, |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
135 varargin{:}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
136 "position", pos); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
137 elseif (nx == nt) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
138 for n = 1:nt |
17041
1b549a0c3ca4
text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16333
diff
changeset
|
139 htmp(n) = __go_text__ (hax, "string", label{n}, |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
140 varargin{:}, |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
141 "position", pos(n,:)); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
142 endfor |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
143 __request_drawnow__ (); |
6405 | 144 else |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
145 error ("text: dimension mismatch for coordinates and LABEL"); |
6405 | 146 endif |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
147 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
|
148 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
|
149 else |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
150 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
|
151 endif |
6257 | 152 |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
153 if (nargout > 0) |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
154 h = htmp; |
6257 | 155 endif |
156 | |
157 endfunction | |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
158 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
159 |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
160 %!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
|
161 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
162 %! ha = {'left', 'center', 'right'}; |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
163 %! 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
|
164 %! 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
|
165 %! y = x; |
11416
74e285bb61c9
text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents:
11272
diff
changeset
|
166 %! 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
|
167 %! 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
|
168 %! 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
|
169 %! 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
|
170 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
171 %! 'horizontalalignment', ha{nh}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
172 %! 'verticalalignment', va{nv}); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
173 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
174 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
175 %! end |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
176 %! 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
|
177 %! 'xticklabel', ha, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
178 %! '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
|
179 %! '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
|
180 %! 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
|
181 %! xlabel ('horizontal alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
182 %! ylabel ('vertical alignment'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
183 %! 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
|
184 |
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
185 %!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
|
186 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
187 %! 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
|
188 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
189 %! 'facealpha', 0); |
11424
bc509d5f763f
text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents:
11416
diff
changeset
|
190 %! 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
|
191 %! 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
|
192 %! 'rotation', t, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
193 %! 'horizontalalignment', 'left', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
194 %! 'verticalalignment', 'bottom'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
195 %! end |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
196 %! caxis ([-100 100]); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
197 %! 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
|
198 |
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 %!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
|
200 %! clf; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13141
diff
changeset
|
201 %! 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
|
202 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
203 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
204 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
205 %! text (4, 4, {'Hello', 'World'}, ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
206 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
207 %! '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
|
208 %! 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
|
209 |
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 %!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
|
211 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
212 %! 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
|
213 %! 'facecolor', 'none', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
214 %! 'facealpha', 0); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
215 %! title (['1st title';'2nd title']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
216 %! xlabel (['1st xlabel';'2nd xlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
217 %! ylabel (['1st ylabel';'2nd ylabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
218 %! zlabel (['1st zlabel';'2nd zlabel']); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
219 %! 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
|
220 %! 'horizontalalignment', 'center', ... |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
221 %! '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
|
222 %! hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
223 %! 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
|
224 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
225 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
226 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
227 %! h = 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
|
228 %! 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
|
229 %! 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
|
230 %! 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
|
231 %! 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
|
232 %! 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
|
233 %! 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
|
234 %! set (h, 'string', 1:3); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
235 %! 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
|
236 %! 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
|
237 %! 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
|
238 %! 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
|
239 %! 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
|
240 %! 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
|
241 %! 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
|
242 %! 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
|
243 %! 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
|
244 %! 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
|
245 %! 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
|
246 %! 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
|
247 %! 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
|
248 %! 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
|
249 %! 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
|
250 %! 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
|
251 %! 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
|
252 %! 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
|
253 %! 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
|
254 |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
255 %!test |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
256 %! 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
|
257 %! unwind_protect |
16333
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
258 %! ## 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
|
259 %! 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
|
260 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
261 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
262 %! 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
|
263 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
264 %! ## Single object with multiple lines |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
265 %! 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
|
266 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
267 %! assert (class (obs), "char"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
268 %! 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
|
269 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
270 %! ## 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
|
271 %! 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
|
272 %! 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
|
273 %! 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
|
274 %! 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
|
275 %! 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
|
276 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
277 %! ## 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
|
278 %! 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
|
279 %! 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
|
280 %! 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
|
281 %! 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
|
282 %! 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
|
283 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
284 %! ### 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
|
285 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
286 %! ## 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
|
287 %! 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
|
288 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
289 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
290 %! 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
|
291 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
292 %! ## 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
|
293 %! 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
|
294 %! "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
|
295 %! obs = get (h, "string"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
296 %! assert (class (obs), "cell"); |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
297 %! 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
|
298 %! "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
|
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 single line |
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.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
|
302 %! 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
|
303 %! 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
|
304 %! ## 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
|
305 %! 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
|
306 %! 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
|
307 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
308 %! ## 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
|
309 %! 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
|
310 %! ## 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
|
311 %! 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
|
312 %! 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
|
313 %! 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
|
314 %! 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
|
315 %! |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
316 %! ## Test special keyword processing |
100a7bd2590e
text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
317 %! 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
|
318 %! 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
|
319 %! 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
|
320 %! 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
|
321 %! |
13136
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
322 %! unwind_protect_cleanup |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
323 %! close (hf); |
79b9a7669bb8
Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents:
12971
diff
changeset
|
324 %! 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
|
325 |