annotate scripts/plot/appearance/text.m @ 17572:7bb76a22cde1

maint: Split scripts/plot directory into 4 pieces. scripts/gui : user-interface functions scripts/plot/appearance : functions controlling plot appearance scripts/plot/draw : plotting functions which produce graphs scripts/plot/util : low-level plotting functions and utilities. * scripts/gui/guidata.m, scripts/gui/guihandles.m, scripts/gui/module.mk, scripts/gui/private/__file_filter__.m, scripts/gui/private/__fltk_file_filter__.m, scripts/gui/private/__is_function__.m, scripts/gui/private/__uigetdir_fltk__.m, scripts/gui/private/__uigetfile_fltk__.m, scripts/gui/private/__uiobject_split_args__.m, scripts/gui/private/__uiputfile_fltk__.m, scripts/gui/uicontextmenu.m, scripts/gui/uicontrol.m, scripts/gui/uigetdir.m, scripts/gui/uigetfile.m, scripts/gui/uimenu.m, scripts/gui/uipanel.m, scripts/gui/uipushtool.m, scripts/gui/uiputfile.m, scripts/gui/uiresume.m, scripts/gui/uitoggletool.m, scripts/gui/uitoolbar.m, scripts/gui/uiwait.m, scripts/gui/waitbar.m, scripts/gui/waitforbuttonpress.m: Moved from scripts/plot to scripts/gui * scripts/plot/appearance/__clabel__.m, scripts/plot/appearance/__getlegenddata__.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m, scripts/plot/appearance/caxis.m, scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m, scripts/plot/appearance/diffuse.m, scripts/plot/appearance/grid.m, scripts/plot/appearance/gtext.m, scripts/plot/appearance/hidden.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m, scripts/plot/appearance/pbaspect.m, scripts/plot/appearance/private/__axis_label__.m, scripts/plot/appearance/private/__axis_limits__.m, scripts/plot/appearance/shading.m, scripts/plot/appearance/specular.m, scripts/plot/appearance/text.m, scripts/plot/appearance/title.m, scripts/plot/appearance/view.m, scripts/plot/appearance/whitebg.m, scripts/plot/appearance/xlabel.m, scripts/plot/appearance/xlim.m, scripts/plot/appearance/ylabel.m, scripts/plot/appearance/ylim.m, scripts/plot/appearance/zlabel.m, scripts/plot/appearance/zlim.m: Moved from scripts/plot to subdir appearance. * scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/comet.m, scripts/plot/draw/comet3.m, scripts/plot/draw/compass.m, scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m, scripts/plot/draw/contourc.m, scripts/plot/draw/contourf.m, scripts/plot/draw/cylinder.m, scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezmeshc.m, scripts/plot/draw/ezplot.m, scripts/plot/draw/ezplot3.m, scripts/plot/draw/ezpolar.m, scripts/plot/draw/ezsurf.m, scripts/plot/draw/ezsurfc.m, scripts/plot/draw/feather.m, scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m, scripts/plot/draw/isocolors.m, scripts/plot/draw/isonormals.m, scripts/plot/draw/isosurface.m, scripts/plot/draw/line.m, scripts/plot/draw/loglog.m, scripts/plot/draw/loglogerr.m, scripts/plot/draw/mesh.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m, scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m, scripts/plot/draw/pcolor.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plot3.m, scripts/plot/draw/plotmatrix.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/polar.m, scripts/plot/draw/private/__add_datasource__.m, scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m, scripts/plot/draw/private/__errcomm__.m, scripts/plot/draw/private/__errplot__.m, scripts/plot/draw/private/__ezplot__.m, scripts/plot/draw/private/__interp_cube__.m, scripts/plot/draw/private/__line__.m, scripts/plot/draw/private/__marching_cube__.m, scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__pie__.m, scripts/plot/draw/private/__plt__.m, scripts/plot/draw/private/__quiver__.m, scripts/plot/draw/private/__scatter__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/quiver.m, scripts/plot/draw/quiver3.m, scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m, scripts/plot/draw/semilogxerr.m, scripts/plot/draw/semilogy.m, scripts/plot/draw/semilogyerr.m, scripts/plot/draw/shrinkfaces.m, scripts/plot/draw/slice.m, scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m, scripts/plot/draw/stem3.m, scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m, scripts/plot/draw/waterfall.m: Moved from plot/ to subdir draw. * scripts/plot/util/__actual_axis_position__.m, scripts/plot/util/__default_plot_options__.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/__next_line_color__.m, scripts/plot/util/__next_line_style__.m, scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/__pltopt__.m, scripts/plot/util/allchild.m, scripts/plot/util/ancestor.m, scripts/plot/util/axes.m, scripts/plot/util/cla.m, scripts/plot/util/clf.m, scripts/plot/util/close.m, scripts/plot/util/closereq.m, scripts/plot/util/colstyle.m, scripts/plot/util/copyobj.m, scripts/plot/util/figure.m, scripts/plot/util/findall.m, scripts/plot/util/findfigs.m, scripts/plot/util/findobj.m, scripts/plot/util/gca.m, scripts/plot/util/gcbf.m, scripts/plot/util/gcbo.m, scripts/plot/util/gcf.m, scripts/plot/util/gco.m, scripts/plot/util/ginput.m, scripts/plot/util/gnuplot_binary.in, scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hdl2struct.m, scripts/plot/util/hggroup.m, scripts/plot/util/hold.m, scripts/plot/util/isaxes.m, scripts/plot/util/isfigure.m, scripts/plot/util/ishghandle.m, scripts/plot/util/ishold.m, scripts/plot/util/isprop.m, scripts/plot/util/linkprop.m, scripts/plot/util/meshgrid.m, scripts/plot/util/ndgrid.m, scripts/plot/util/newplot.m, scripts/plot/util/print.m, scripts/plot/util/printd.m, scripts/plot/util/private/__add_default_menu__.m, scripts/plot/util/private/__fltk_ginput__.m, scripts/plot/util/private/__fltk_print__.m, scripts/plot/util/private/__ghostscript__.m, scripts/plot/util/private/__gnuplot_get_var__.m, scripts/plot/util/private/__gnuplot_ginput__.m, scripts/plot/util/private/__gnuplot_has_feature__.m, scripts/plot/util/private/__gnuplot_has_terminal__.m, scripts/plot/util/private/__gnuplot_open_stream__.m, scripts/plot/util/private/__gnuplot_print__.m, scripts/plot/util/private/__gnuplot_version__.m, scripts/plot/util/private/__go_draw_axes__.m, scripts/plot/util/private/__go_draw_figure__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/private/__tight_eps_bbox__.m, scripts/plot/util/refresh.m, scripts/plot/util/refreshdata.m, scripts/plot/util/saveas.m, scripts/plot/util/shg.m, scripts/plot/util/struct2hdl.m, scripts/plot/util/subplot.m: Moved from plot to subdir util. * etc/HACKING: Updated directory structure info. * scripts/Makefile.am, scripts/plot/appearance/module.mk, scripts/plot/draw/module.mk, scripts/plot/util/module.mk: Added new directories to build system.
author Rik <rik@octave.org>
date Fri, 04 Oct 2013 17:09:08 -0700
parents scripts/plot/text.m@4166048ba6cf
children d63878346099
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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 -*-
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{})
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
24 ## Create a text object with text @var{string} at position @var{x}, @var{y},
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
25 ## (@var{z}) on the current axes.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17041
diff changeset
26 ##
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
27 ## Multiple locations can be specified if @var{x}, @var{y}, (@var{z}) are
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
28 ## vectors. Multiple strings can be specified with a character matrix or
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
29 ## a cell array of strings.
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
30 ##
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
31 ## Optional property/value pairs may be used to control the appearance of the
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
32 ## text.
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
33 ##
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
34 ## The optional return value @var{h} is a vector of graphics handles to the
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
35 ## created text objects.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17041
diff changeset
36 ## @seealso{gtext, title, xlabel, ylabel, zlabel}
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
37 ## @end deftypefn
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
38
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
39 ## Author: jwe
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
40
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
41 ## 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
42 ## 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
43
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
44 function h = text (varargin)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
45
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
46 nargs = nargin;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
47 offset = 0;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
48
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
49 if (nargs > 2 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
50 x = varargin{1};
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
51 y = varargin{2};
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
52
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
53 if (nargin > 3 && isnumeric (varargin{3}))
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
54 z = varargin{3};
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
55 offset = 4;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
56 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
57 z = zeros (size (x));
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
58 offset = 3;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
59 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
60
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
61 string = varargin{offset};
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
62 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
63
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 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
65 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
66 nz = numel (z);
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
67 if (ischar (string))
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
68
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
69 do_keyword_repl = true;
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
70 nt = rows (string);
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
71 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
72 ## Single text object with one line
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
73 string = {string};
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
74 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
75 ## 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
76 ## 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
77 ## 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
78 ## 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
79 do_keyword_repl = false;
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
80 string = {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
81 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
82 ## Mutiple text objects with different strings
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
83 string = cellstr (string);
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
84 else
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
85 ## Mutiple text objects with same string
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
86 string = repmat ({string}, [nx, 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
87 nt = nx;
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
88 endif
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
89
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
90 ## Escape special keywords
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
91 if (do_keyword_repl)
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
92 string = regexprep (string, '^(default|factory)$', '\\$1');
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
93 endif
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
94
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
95 elseif (iscell (string))
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
96
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
97 nt = numel (string);
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
98 if (nx == 1)
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
99 ## Single text object with one or more lines
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
100 string = {string};
12971
e65d1488ff6a text.m: Improve logic and error checking. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents: 12965
diff changeset
101 nt = 1;
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
102 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
103 ## 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
104 else
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
105 ## Mutiple text objects with same string
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
106 string = repmat ({string}, [nx, 1]);
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
107 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
108 endif
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
109
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
110 else
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
111
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
112 error ("text: STRING must be a character string or cell array of character strings");
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
113
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
114 endif
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
115 else # Only PROP/VALUE pairs
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
116 x = y = z = 0;
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
117 nx = ny = nz = 1;
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
118 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
119 nt = 1;
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
120 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
121
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
122 ## 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
123 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
124 print_usage ();
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
125 endif
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
126
17041
1b549a0c3ca4 text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 16333
diff changeset
127 ## 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
128 [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
129
1b549a0c3ca4 text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 16333
diff changeset
130 if (isempty (hax))
1b549a0c3ca4 text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 16333
diff changeset
131 hax = gca ();
1b549a0c3ca4 text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 16333
diff changeset
132 endif
1b549a0c3ca4 text.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 16333
diff changeset
133
17566
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
134 ## Position argument may alse be in PROP/VAL pair
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
135 idx = find (strcmpi (varargin, "position"), 1);
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
136 if (idx)
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
137 pos = varargin{idx+1};
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
138 varargin(idx:idx+1) = [];
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
139 else
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
140 pos = [x(:), y(:), z(:)];
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
141 endif
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
142
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
143 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
144 htmp = zeros (nt, 1);
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
145 if (nx == 1)
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
146 htmp = __go_text__ (hax, "string", string{1},
17566
4166048ba6cf text.m: Fix text location if "Position" specified as prop/value pair.
Rik <rik@octave.org>
parents: 17497
diff changeset
147 ## varargin first, in case "Units" set for pos.
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
148 varargin{:},
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
149 "position", pos);
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
150 elseif (nx == nt)
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
151 for n = 1:nt
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
152 htmp(n) = __go_text__ (hax, "string", string{n},
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
153 varargin{:},
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
154 "position", pos(n,:));
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
155 endfor
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
156 __request_drawnow__ ();
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
157 else
17497
96cf8ee3440e text.m: Match variable names to documentation.
Rik <rik@octave.org>
parents: 17122
diff changeset
158 error ("text: dimension mismatch for coordinates and STRING");
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents: 6257
diff changeset
159 endif
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
160 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
161 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
162 else
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
163 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
164 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
165
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
166 if (nargout > 0)
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
167 h = htmp;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
168 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
169
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
170 endfunction
11416
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
171
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
172
11416
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
173 %!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
174 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
175 %! ha = {'left', 'center', 'right'};
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
176 %! 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
177 %! 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
178 %! y = x;
11416
74e285bb61c9 text.m: Add demo for text rotation and alignment.
Ben Abbott <bpabbott@mac.com>
parents: 11272
diff changeset
179 %! 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
180 %! 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
181 %! 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
182 %! 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
183 %! 'rotation', t, ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
184 %! 'horizontalalignment', ha{nh}, ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
185 %! 'verticalalignment', va{nv});
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
186 %! end
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
187 %! end
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
188 %! end
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
189 %! 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
190 %! 'xticklabel', ha, ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
191 %! '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
192 %! '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
193 %! 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
194 %! xlabel ('horizontal alignment');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
195 %! ylabel ('vertical alignment');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
196 %! 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
197
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
198 %!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
199 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
200 %! 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
201 %! 'facecolor', 'none', ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
202 %! 'facealpha', 0);
11424
bc509d5f763f text.m: New demo for 3D plot and text with verticalalignment.
Ben Abbott <bpabbott@mac.com>
parents: 11416
diff changeset
203 %! 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
204 %! 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
205 %! 'rotation', t, ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
206 %! 'horizontalalignment', 'left', ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
207 %! 'verticalalignment', 'bottom');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
208 %! end
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
209 %! caxis ([-100 100]);
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
210 %! 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
211
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
212 %!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
213 %! clf;
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13141
diff changeset
214 %! 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
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 %! text (4, 4, {'Hello', 'World'}, ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
219 %! 'horizontalalignment', 'center', ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
220 %! '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
221 %! 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
222
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
223 %!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
224 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
225 %! 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
226 %! 'facecolor', 'none', ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
227 %! 'facealpha', 0);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
228 %! title (['1st title';'2nd title']);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
229 %! xlabel (['1st xlabel';'2nd xlabel']);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
230 %! ylabel (['1st ylabel';'2nd ylabel']);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
231 %! zlabel (['1st zlabel';'2nd zlabel']);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
232 %! 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
233 %! 'horizontalalignment', 'center', ...
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
234 %! '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
235 %! hold on;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
236 %! 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
237
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12437
diff changeset
238 %!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
239 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
240 %! 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
241 %! 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
242 %! 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
243 %! 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
244 %! 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
245 %! 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
246 %! 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
247 %! set (h, 'string', 1:3);
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
248 %! 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
249 %! 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
250 %! 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
251 %! 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
252 %! 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
253 %! 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
254 %! 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
255 %! 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
256 %! 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
257 %! 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
258 %! 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
259 %! 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
260 %! 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
261 %! 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
262 %! 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
263 %! 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
264 %! 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
265 %! 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
266 %! 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
267
13136
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
268 %!test
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
269 %! 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
270 %! unwind_protect
16333
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
271 %! ## 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
272 %! 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
273 %! obs = get (h, "string");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
274 %! assert (class (obs), "char");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
275 %! 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
276 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
277 %! ## Single object with multiple lines
13136
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
278 %! 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
279 %! obs = get (h, "string");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
280 %! assert (class (obs), "char");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
281 %! 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
282 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
283 %! ## 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
284 %! 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
285 %! 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
286 %! 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
287 %! 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
288 %! 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
289 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
290 %! ## 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
291 %! 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
292 %! 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
293 %! 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
294 %! 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
295 %! 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
296 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
297 %! ### 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
298 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
299 %! ## 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
300 %! 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
301 %! obs = get (h, "string");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
302 %! assert (class (obs), "cell");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
303 %! 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
304 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
305 %! ## 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
306 %! 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
307 %! "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
308 %! obs = get (h, "string");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
309 %! assert (class (obs), "cell");
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
310 %! 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
311 %! "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
312 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
313 %! ## 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
314 %! 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
315 %! 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
316 %! 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
317 %! ## 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
318 %! 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
319 %! 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
320 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
321 %! ## 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
322 %! 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
323 %! ## 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
324 %! 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
325 %! 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
326 %! 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
327 %! 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
328 %!
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
329 %! ## Test special keyword processing
100a7bd2590e text.m: Fix null label if string is "default" (bug #36156)
Rik <rik@octave.org>
parents: 14872
diff changeset
330 %! 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
331 %! 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
332 %! 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
333 %! 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
334 %!
13136
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
335 %! unwind_protect_cleanup
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
336 %! close (hf);
79b9a7669bb8 Tests added for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12971
diff changeset
337 %! 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
338