annotate scripts/plot/grid.m @ 14237:11949c9795a0

Revamp %!demos in m-files to use Octave coding conventions on spacing, etc. Add clf() to all demos using plot features to get reproducibility. Use 64 as input to all colormaps (jet (64)) to get reproducibility. * bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m, interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m, griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m, copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m, ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m, condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m, pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m, subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m, triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m, waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m, bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m, example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m, weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author Rik <octave@nomad.inbox5.com>
date Fri, 20 Jan 2012 12:59:53 -0800
parents 72c96de7a403
children 4506eade9f04
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: 11523
diff changeset
1 ## Copyright (C) 1993-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
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.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
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/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} grid (@var{arg})
5727
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
21 ## @deftypefnx {Function File} {} grid ("minor", @var{arg2})
8528
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
22 ## @deftypefnx {Function File} {} grid (@var{hax}, @dots{})
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
23 ## Force the display of a grid on the plot.
8528
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
24 ## The argument may be either @code{"on"}, or @code{"off"}.
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
25 ## If it is omitted, the current grid state is toggled.
5727
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
26 ##
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6828
diff changeset
27 ## If @var{arg} is @code{"minor"} then the minor grid is toggled. When
5727
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
28 ## using a minor grid a second argument @var{arg2} is allowed, which can
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
29 ## be either @code{"on"} or @code{"off"} to explicitly set the state of
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
30 ## the minor grid.
8528
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
31 ##
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
32 ## If the first argument is an axis handle, @var{hax}, operate on the
06e1667d7492 grid.m: Correct doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 8507
diff changeset
33 ## specified axis object.
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6828
diff changeset
34 ## @seealso{plot}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 2847
diff changeset
35 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
36
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
37 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
38
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
39 function grid (varargin)
5727
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
40
9374
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
41 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:});
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
42
9374
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
43 grid_on = (strcmp (get (ax, "xgrid"), "on")
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
44 && strcmp (get (ax, "ygrid"), "on")
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
45 && strcmp (get (ax, "zgrid"), "on"));
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
46
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
47 minor_on = (strcmp (get (ax, "xminorgrid"), "on")
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
48 && strcmp (get (ax, "yminorgrid"), "on")
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
49 && strcmp (get (ax, "zminorgrid"), "on"));
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
50
8424
a84d71abdc5b grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents: 8190
diff changeset
51 if (nargs > 2)
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
52 print_usage ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
53 elseif (nargs == 0)
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
54 grid_on = ! grid_on;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
55 else
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7017
diff changeset
56 x = varargin{1};
5443
ec8c33dcd1bf [project @ 2005-09-08 01:40:57 by jwe]
jwe
parents: 5307
diff changeset
57 if (ischar (x))
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7216
diff changeset
58 if (strcmpi (x, "off"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
59 grid_on = false;
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7216
diff changeset
60 elseif (strcmpi (x, "on"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
61 grid_on = true;
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 7216
diff changeset
62 elseif (strcmpi (x, "minor"))
8424
a84d71abdc5b grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents: 8190
diff changeset
63 if (nargs == 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
64 x2 = varargin{2};
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
65 if (strcmpi (x2, "on"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
66 minor_on = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
67 grid_on = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
68 elseif (strcmpi (x2, "off"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
69 minor_on = false;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
70 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
71 print_usage ();
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
72 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
73 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
74 minor_on = ! minor_on;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
75 if (minor_on)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
76 grid_on = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
77 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
78 endif
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
79 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9374
diff changeset
80 print_usage ();
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
81 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
82 else
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 245
diff changeset
83 error ("grid: argument must be a string");
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
84 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
85 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
86
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
87 if (grid_on)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
88 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
89 if (minor_on)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
90 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on");
5727
f0fbefd984f6 [project @ 2006-04-03 18:50:31 by jwe]
jwe
parents: 5642
diff changeset
91 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
92 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
93 endif
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
94 else
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
95 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6046
diff changeset
96 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5053
diff changeset
97 endif
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5053
diff changeset
98
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
99 endfunction
9374
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
100
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
101
9374
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
102 %!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
103 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
104 %! subplot (2,2,1);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
105 %! plot (1:100);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106 %! grid off;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
107 %! title ("no grid");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
108 %! subplot (2,2,2);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
109 %! plot (1:100);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110 %! grid on;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
111 %! title ("grid on");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
112 %! subplot (2,2,3);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
113 %! plot (1:100);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
114 %! grid minor;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
115 %! title ("grid minor");
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
116 %! subplot (2,2,4);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
117 %! semilogy (1:100);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
118 %! grid minor;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
119 %! title ("grid minor");
9374
6a035159ba0e grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
120