Mercurial > hg > octave-nkf
annotate scripts/plot/grid.m @ 8208:f6ca8ff51818
[mq]: graphics-backend
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 10 Oct 2008 11:07:53 -0400 |
parents | 73d6b71788c0 |
children | a84d71abdc5b |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2003, 2004, |
2 ## 2005, 2006, 2007 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}) |
6257 | 23 ## Force the display of a grid on the plot. |
3368 | 24 ## The argument may be either @code{"on"} or @code{"off"}. If it is |
6653 | 25 ## omitted, the current grid state is toggled. |
5727 | 26 ## |
6895 | 27 ## If @var{arg} is @code{"minor"} then the minor grid is toggled. When |
5727 | 28 ## using a minor grid a second argument @var{arg2} is allowed, which can |
29 ## be either @code{"on"} or @code{"off"} to explicitly set the state of | |
6257 | 30 ## the minor grid. |
6895 | 31 ## @seealso{plot} |
3368 | 32 ## @end deftypefn |
4 | 33 |
2314 | 34 ## Author: jwe |
35 | |
4264 | 36 ## PKG_ADD: mark_as_command grid |
37 | |
7215 | 38 function grid (varargin) |
5727 | 39 |
40 persistent grid_on = false; | |
41 persistent minor_on = false; | |
6257 | 42 |
7215 | 43 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:}); |
7216 | 44 |
7215 | 45 if (nargs > 1) |
46 print_usage (); | |
47 elseif (nargs == 0) | |
48 grid_on = ! grid_on; | |
6257 | 49 else |
7215 | 50 x = varargin{1}; |
5443 | 51 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
|
52 if (strcmpi (x, "off")) |
5727 | 53 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
|
54 elseif (strcmpi (x, "on")) |
5727 | 55 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
|
56 elseif (strcmpi (x, "minor")) |
5727 | 57 minor_on = ! minor_on; |
58 if (minor_on) | |
6257 | 59 grid_on = true; |
5727 | 60 endif |
4 | 61 else |
6046 | 62 print_usage (); |
4 | 63 endif |
64 else | |
904 | 65 error ("grid: argument must be a string"); |
4 | 66 endif |
6257 | 67 endif |
68 | |
69 if (grid_on) | |
70 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
71 if (minor_on) | |
72 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on"); | |
5727 | 73 else |
6257 | 74 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); |
75 endif | |
4 | 76 else |
6257 | 77 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off"); |
78 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); | |
5152 | 79 endif |
80 | |
4 | 81 endfunction |