Mercurial > hg > octave-lyh
annotate scripts/plot/grid.m @ 9051:1bf0ce0930be
Grammar check TexInfo in all .m files
Cleanup documentation sources to follow a few consistent rules.
Spellcheck was NOT done. (but will be in another changeset)
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 27 Mar 2009 22:31:03 -0700 |
parents | eb63fbe60fab |
children | 6a035159ba0e |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2003, 2004, |
8920 | 2 ## 2005, 2006, 2007, 2008, 2009 John W. Eaton |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
245 | 19 |
3368 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} grid (@var{arg}) | |
5727 | 22 ## @deftypefnx {Function File} {} grid ("minor", @var{arg2}) |
8528 | 23 ## @deftypefnx {Function File} {} grid (@var{hax}, @dots{}) |
6257 | 24 ## Force the display of a grid on the plot. |
8528 | 25 ## The argument may be either @code{"on"}, or @code{"off"}. |
26 ## If it is omitted, the current grid state is toggled. | |
5727 | 27 ## |
6895 | 28 ## If @var{arg} is @code{"minor"} then the minor grid is toggled. When |
5727 | 29 ## using a minor grid a second argument @var{arg2} is allowed, which can |
30 ## be either @code{"on"} or @code{"off"} to explicitly set the state of | |
6257 | 31 ## the minor grid. |
8528 | 32 ## |
33 ## If the first argument is an axis handle, @var{hax}, operate on the | |
34 ## specified axis object. | |
6895 | 35 ## @seealso{plot} |
3368 | 36 ## @end deftypefn |
4 | 37 |
2314 | 38 ## Author: jwe |
39 | |
7215 | 40 function grid (varargin) |
5727 | 41 |
42 persistent grid_on = false; | |
43 persistent minor_on = false; | |
6257 | 44 |
7215 | 45 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:}); |
7216 | 46 |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
47 if (nargs > 2) |
7215 | 48 print_usage (); |
49 elseif (nargs == 0) | |
50 grid_on = ! grid_on; | |
6257 | 51 else |
7215 | 52 x = varargin{1}; |
5443 | 53 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
|
54 if (strcmpi (x, "off")) |
5727 | 55 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
|
56 elseif (strcmpi (x, "on")) |
5727 | 57 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
|
58 elseif (strcmpi (x, "minor")) |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
59 if (nargs == 2) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
60 x2 = varargin{2}; |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
61 if (strcmpi (x2, "on")) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
62 minor_on = true; |
8507 | 63 grid_on = true; |
8501 | 64 elseif (strcmpi (x2, "off")) |
65 minor_on = false; | |
66 else | |
67 print_usage (); | |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
68 endif |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
69 else |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
70 minor_on = ! minor_on |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
71 if (minor_on) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
72 grid_on = true; |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
73 endif |
5727 | 74 endif |
4 | 75 else |
6046 | 76 print_usage (); |
4 | 77 endif |
78 else | |
904 | 79 error ("grid: argument must be a string"); |
4 | 80 endif |
6257 | 81 endif |
82 | |
83 if (grid_on) | |
84 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
85 if (minor_on) | |
86 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on"); | |
5727 | 87 else |
6257 | 88 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); |
89 endif | |
4 | 90 else |
6257 | 91 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off"); |
92 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); | |
5152 | 93 endif |
94 | |
4 | 95 endfunction |