comparison scripts/plot/util/subplot.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/subplot.m@fedcd3717ebc
children d63878346099
comparison
equal deleted inserted replaced
17571:6e4ea5c8a4bb 17572:7bb76a22cde1
1 ## Copyright (C) 1995-2012 John W. Eaton
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
21 ## @deftypefnx {Function File} {} subplot (@var{rcn})
22 ## @deftypefnx {Function File} {} subplot (@var{hax})
23 ## @deftypefnx {Function File} {} subplot (@dots{}, "align")
24 ## @deftypefnx {Function File} {} subplot (@dots{}, "replace")
25 ## @deftypefnx {Function File} {} subplot (@dots{}, "position", @var{pos})
26 ## @deftypefnx {Function File} {} subplot (@dots{}, @var{prop}, @var{val}, @dots{})
27 ## @deftypefnx {Function File} {@var{hax} =} subplot (@dots{})
28 ## Set up a plot grid with @var{rows} by @var{cols} subwindows and set the
29 ## current axes for plotting (@code{gca}) to the location given by @var{index}.
30 ##
31 ## If only one numeric argument is supplied, then it must be a three digit
32 ## value specifying the number of rows in digit 1, the number of
33 ## columns in digit 2, and the plot index in digit 3.
34 ##
35 ## The plot index runs row-wise; First, all columns in a row are numbered
36 ## and then the next row is filled.
37 ##
38 ## For example, a plot with 2x3 grid will have plot indices running as follows:
39 ## @tex
40 ## \vskip 10pt
41 ## \hfil\vbox{\offinterlineskip\hrule
42 ## \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr
43 ## height13pt&1&2&3\cr height12pt&&&\cr\noalign{\hrule}
44 ## height13pt&4&5&6\cr height12pt&&&\cr\noalign{\hrule}}}
45 ## \hfil
46 ## \vskip 10pt
47 ## @end tex
48 ## @ifnottex
49 ##
50 ## @example
51 ## @group
52 ## +-----+-----+-----+
53 ## | 1 | 2 | 3 |
54 ## +-----+-----+-----+
55 ## | 4 | 5 | 6 |
56 ## +-----+-----+-----+
57 ## @end group
58 ## @end example
59 ##
60 ## @end ifnottex
61 ##
62 ## @var{index} may also be a vector. In this case, the new axis will enclose
63 ## the grid locations specified. The first demo illustrates this:
64 ##
65 ## @example
66 ## demo ("subplot", 1)
67 ## @end example
68 ##
69 ## The index of the subplot to make active may also be specified by its axes
70 ## handle, @var{hax}, returned from a previous @code{subplot} command.
71 ##
72 ## If the option @qcode{"align"} is given then the plot boxes of the subwindows
73 ## will align, but this may leave no room for axis tick marks or labels.
74 ##
75 ## If the option @qcode{"replace"} is given then the subplot axis will be
76 ## reset, rather than just switching the current axis for plotting to the
77 ## requested subplot.
78 ##
79 ## The @qcode{"position"} property can be used to exactly position the subplot
80 ## axes within the current figure. The option @var{pos} is a 4-element vector
81 ## [x, y, width, height] that determines the location and size of the axes.
82 ## The values in @var{pos} are normalized in the range [0,1].
83 ##
84 ## Any property/value pairs are passed directly to the underlying axes object.
85 ##
86 ## If the output @var{hax} is requested, subplot returns the axis handle for
87 ## the subplot. This is useful for modifying the properties of a subplot
88 ## using @code{set}.
89 ## @seealso{axes, plot, gca, set}
90 ## @end deftypefn
91
92 ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU>
93 ## Adapted-By: jwe
94
95 function h = subplot (varargin)
96
97 align_axes = false;
98 replace_axes = false;
99 have_position = false;
100 initial_args_decoded = false;
101
102 if (nargin >= 3)
103 ## R, C, N?
104 arg1 = varargin{1};
105 arg2 = varargin{2};
106 arg3 = varargin{3};
107 if ( isnumeric (arg1) && isscalar (arg1)
108 && isnumeric (arg2) && isscalar (arg2)
109 && isnumeric (arg3))
110 rows = arg1;
111 cols = arg2;
112 index = arg3;
113 varargin(1:3) = [];
114 initial_args_decoded = true;
115 endif
116 endif
117
118 if (! initial_args_decoded && nargin > 1)
119 ## check for "position", pos, ...
120 if (strcmpi (varargin{1}, "position"))
121 arg = varargin{2};
122 if (isnumeric (arg) && numel (arg) == 4)
123 pos = arg;
124 varargin(1:2) = [];
125 have_position = true;
126 initial_args_decoded = true;
127 else
128 error ("subplot: POSITION must be a 4-element numeric array");
129 endif
130 endif
131 endif
132
133 if (! initial_args_decoded && nargin > 0)
134 arg = varargin{1};
135 if (nargin == 1 && isaxes (arg))
136 ## Axes handle
137 axes (arg);
138 cf = get (0, "currentfigure");
139 set (cf, "nextplot", "add");
140 return;
141 elseif (isscalar (arg) && arg >= 0)
142 ## RCN?
143 index = rem (arg, 10);
144 arg = (arg - index) / 10;
145 cols = rem (arg, 10);
146 arg = (arg - cols) / 10;
147 rows = rem (arg, 10);
148 varargin(1) = [];
149 initial_args_decoded = true;
150 else
151 error ("subplot: expecting axes handle or RCN argument");
152 endif
153 endif
154
155 if (! initial_args_decoded)
156 print_usage ();
157 endif
158
159 if (! have_position)
160 cols = round (cols);
161 rows = round (rows);
162 index = round (index);
163
164 if (any (index < 1) || any (index > rows*cols))
165 error ("subplot: INDEX value must be >= 1 and <= ROWS*COLS");
166 endif
167
168 if (rows < 1 || cols < 1 || index < 1)
169 error ("subplot: ROWS, COLS, and INDEX must be be positive");
170 endif
171 endif
172
173 ## Process "align" and "replace" options
174 idx = strcmpi (varargin, "align");
175 if (any (idx))
176 align_axes = true;
177 varargin(idx) = [];
178 endif
179
180 idx = strcmpi (varargin, "replace");
181 if (any (idx))
182 replace_axes = true;
183 varargin(idx) = [];
184 endif
185
186 axesunits = get (0, "defaultaxesunits");
187 cf = gcf ();
188 figureunits = get (cf, "units");
189 unwind_protect
190 set (0, "defaultaxesunits", "normalized");
191 set (cf, "units", "pixels");
192
193 ## FIXME: At the moment we force gnuplot to use the aligned mode
194 ## which will set "activepositionproperty" to "position".
195 ## Τhis can yield to text overlap between labels and titles
196 ## see bug #31610
197 if (strcmp (get (cf, "__graphics_toolkit__"), "gnuplot"))
198 align_axes = true;
199 endif
200
201 if (! have_position)
202 pos = subplot_position (rows, cols, index, "position");
203 outerpos = subplot_position (rows, cols, index, "outerposition");
204 box = [pos(1:2), pos(1:2)+pos(3:4)];
205 outerbox = [outerpos(1:2), outerpos(1:2)+outerpos(3:4)];
206 looseinset = [box(1:2)-outerbox(1:2), outerbox(3:4)-box(3:4)];
207 if (align_axes)
208 activepositionproperty = "position";
209 else
210 activepositionproperty = "outerposition";
211 endif
212 endif
213
214 set (cf, "nextplot", "add");
215
216 found = false;
217 kids = get (cf, "children");
218 for child = kids(:)'
219 ## Check whether this child is still valid; this might not be the
220 ## case anymore due to the deletion of previous children (due to
221 ## "deletefcn" callback or for legends/colorbars that are deleted
222 ## with their corresponding axes).
223 if (! ishandle (child))
224 continue;
225 endif
226 if (strcmp (get (child, "type"), "axes"))
227 ## Skip legend and colorbar objects.
228 if (any (strcmp (get (child, "tag"), {"legend", "colorbar"})))
229 continue;
230 endif
231 objpos = get (child, "outerposition");
232 if (all (abs (objpos - outerpos) < eps) && ! replace_axes)
233 ## If the new axes are in exactly the same position
234 ## as an existing axes object, use the existing axes.
235 found = true;
236 hsubplot = child;
237 else
238 ## If the new axes overlap an old axes object, delete the old axes.
239 if (align_axes)
240 objpos = get (child, "position");
241 endif
242 x0 = pos(1);
243 x1 = x0 + pos(3);
244 y0 = pos(2);
245 y1 = y0 + pos(4);
246 objx0 = objpos(1);
247 objx1 = objx0 + objpos(3);
248 objy0 = objpos(2);
249 objy1 = objy0 + objpos(4);
250 if (! (x0 >= objx1 || x1 <= objx0 || y0 >= objy1 || y1 <= objy0))
251 delete (child);
252 endif
253 endif
254 endif
255 endfor
256
257 if (found)
258 ## Switch to existing subplot
259 set (cf, "currentaxes", hsubplot);
260 else
261 hsubplot = axes ("box", "off",
262 "position", pos,
263 "looseinset", looseinset,
264 "activepositionproperty", activepositionproperty,
265 varargin{:});
266 addproperty ("subplot_align", hsubplot, "boolean", true);
267 addlistener (hsubplot, "position", @subplot_align);
268 if (! align_axes)
269 set (hsubplot, "subplot_align", false)
270 subplot_align (hsubplot)
271 endif
272 endif
273
274 unwind_protect_cleanup
275 set (0, "defaultaxesunits", axesunits);
276 set (cf, "units", figureunits);
277 end_unwind_protect
278
279 if (nargout > 0)
280 h = hsubplot;
281 endif
282
283 endfunction
284
285 function pos = subplot_position (rows, cols, index, position_property)
286
287 if (rows == 1 && cols == 1)
288 ## Trivial result for subplot (1,1,1)
289 if (strcmpi (position_property, "position"))
290 pos = get (0, "defaultaxesposition");
291 else
292 pos = get (0, "defaultaxesouterposition");
293 endif
294 return;
295 endif
296
297 if (strcmp (position_property, "outerposition"))
298 margins.left = 0.05;
299 margins.bottom = 0.05;
300 margins.right = 0.05;
301 margins.top = 0.05;
302 margins.column = 0.04 / cols;
303 margins.row = 0.04 / rows;
304 width = 1 - margins.left - margins.right - (cols-1)*margins.column;
305 width = width / cols;
306 height = 1 - margins.top - margins.bottom - (rows-1)*margins.row;
307 height = height / rows;
308 else
309 defaultaxesposition = get (0, "defaultaxesposition");
310
311 ## The outer margins surrounding all subplot "positions" are independent
312 ## of the number of rows and/or columns
313 margins.left = defaultaxesposition(1);
314 margins.bottom = defaultaxesposition(2);
315 margins.right = 1.0 - margins.left - defaultaxesposition(3);
316 margins.top = 1.0 - margins.bottom - defaultaxesposition(4);
317
318 ## Fit from Matlab experiments
319 pc = 1 ./ [0.1860, (margins.left + margins.right - 1)];
320 margins.column = 1 ./ polyval (pc , cols);
321 pr = 1 ./ [0.2282, (margins.top + margins.bottom - 1)];
322 margins.row = 1 ./ polyval (pr , rows);
323
324 ## Calculate the width/height of the subplot axes "position".
325 ## This is also consistent with Matlab
326 width = 1 - margins.left - margins.right - (cols-1)*margins.column;
327 width = width / cols;
328 height = 1 - margins.top - margins.bottom - (rows-1)*margins.row;
329 height = height / rows;
330 endif
331
332 ## Index offsets from the lower left subplot
333 yi = fix ((index(:)-1)/cols);
334 xi = index(:) - yi*cols - 1;
335 yi = (rows - 1) - yi;
336
337 ## Lower left corner of the subplot, i.e., position(1:2)
338 x0 = xi .* (width + margins.column) + margins.left;
339 y0 = yi .* (height + margins.row) + margins.bottom;
340
341 if (numel (x0) > 1)
342 ## subplot (row, col, m:n)
343 x1 = max (x0(:)) + width;
344 y1 = max (y0(:)) + height;
345 x0 = min (x0(:));
346 y0 = min (y0(:));
347 pos = [x0, y0, x1-x0, y1-y0];
348 else
349 ## subplot (row, col, num)
350 pos = [x0, y0, width, height];
351 endif
352
353 endfunction
354
355 function subplot_align (h, varargin)
356 persistent updating = false;
357
358 if (! updating)
359 unwind_protect
360 updating = true;
361 hfig = ancestor (h, "figure");
362 hsubplots = findall (hfig, "type", "axes", "subplot_align", "off");
363 if (! isempty (hsubplots))
364 tightinset = get (hsubplots, "tightinset");
365 if (iscell (tightinset))
366 tightinset = max (cell2mat (tightinset));
367 endif
368 looseinset = get (hsubplots, "looseinset");
369 if (iscell (looseinset))
370 looseinset = max (cell2mat (looseinset));
371 endif
372 looseinset = max (tightinset, looseinset);
373 set (hsubplots, "looseinset", looseinset);
374 endif
375 unwind_protect_cleanup
376 updating = false;
377 end_unwind_protect
378 endif
379
380 endfunction
381
382
383 %!demo
384 %! clf;
385 %! r = 3;
386 %! c = 3;
387 %! fmt = {'horizontalalignment', 'center', 'verticalalignment', 'middle'};
388 %! for n = 1 : r*c
389 %! subplot (r, c, n);
390 %! xlabel (sprintf ('xlabel #%d', n));
391 %! ylabel (sprintf ('ylabel #%d', n));
392 %! title (sprintf ('title #%d', n));
393 %! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d)', r, c, n), fmt{:});
394 %! axis ([0 1 0 1]);
395 %! end
396 %! subplot (r, c, 1:3);
397 %! xlabel (sprintf ('xlabel #%d:%d', 1, 3));
398 %! ylabel (sprintf ('ylabel #%d:%d', 1, 3));
399 %! title (sprintf ('title #%d:%d', 1, 3));
400 %! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:});
401 %! axis ([0 1 0 1]);
402
403 %!demo
404 %! clf;
405 %! x = 0:1;
406 %! for n = 1:4
407 %! subplot (2,2,n, 'align');
408 %! plot (x, x);
409 %! xlabel (sprintf ('xlabel (2,2,%d)', n));
410 %! ylabel (sprintf ('ylabel (2,2,%d)', n));
411 %! title (sprintf ('title (2,2,%d)', n));
412 %! end
413 %! subplot (1,2,1, 'align');
414 %! plot (x, x);
415 %! xlabel ('xlabel (1,2,1)');
416 %! ylabel ('ylabel (1,2,1)');
417 %! title ('title (1,2,1)');
418
419 %!demo
420 %! clf;
421 %! x = 0:10;
422 %! ax(1) = subplot (221);
423 %! set (ax(1), 'tag', '1');
424 %! plot (x, rand (3, 11))
425 %! title ('x & y labels & ticklabels');
426 %! xlabel xlabel
427 %! ylabel ylabel
428 %! ax(2) = subplot (222);
429 %! set (ax(2), 'tag', '2');
430 %! plot (x, rand (3, 11))
431 %! title ('no labels');
432 %! axis ('nolabel','tic')
433 %! ax(3) = subplot (223);
434 %! set (ax(3), 'tag', '3');
435 %! plot (x, rand (3, 11))
436 %! title ('no labels');
437 %! axis ('nolabel','tic')
438 %! ax(4) = subplot (224);
439 %! set (ax(4), 'tag', '4');
440 %! plot (x, rand (3, 11))
441 %! title ('x & y labels & ticklabels');
442 %! xlabel xlabel
443 %! ylabel ylabel
444
445 %!demo
446 %! x = 0:10;
447 %! subplot (221);
448 %! plot (x, rand (3, 11))
449 %! ylim ([0, 1]);
450 %! text (0.5, 0.5, '{x,y}labels & {x,y}ticklabels', ...
451 %! 'horizontalalignment', 'center', ...
452 %! 'units', 'normalized');
453 %! xlabel xlabel
454 %! ylabel ylabel
455 %! title title
456 %! subplot (222);
457 %! plot (x, rand (3, 11))
458 %! axis ('labely');
459 %! ylabel ylabel
460 %! text (0.5, 0.5, 'no xlabels, xticklabels', ...
461 %! 'horizontalalignment', 'center', ...
462 %! 'units', 'normalized');
463 %! subplot (223);
464 %! plot (x, rand (3, 11))
465 %! axis ('labelx');
466 %! text (0.5, 0.5, 'no ylabels, yticklabels', ...
467 %! 'horizontalalignment', 'center', ...
468 %! 'units', 'normalized');
469 %! xlabel xlabel
470 %! title title
471 %! subplot (224);
472 %! plot (x, rand (3, 11))
473 %! axis ('nolabel','tic');
474 %! text (0.5, 0.5, 'no {x,y}labels, {x,y}ticklabels', ...
475 %! 'horizontalalignment', 'center', ...
476 %! 'units', 'normalized');
477