1## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2003, 2004,
2## 2005, 2006, 2007, 2008, 2009 John W. Eaton
4## This file is part of Octave.
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
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
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.
16## You should have received a copy of the GNU General Public License
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
21## @deftypefn {Function File} {} grid (@var{arg})
22## @deftypefnx {Function File} {} grid ("minor", @var{arg2})
23## @deftypefnx {Function File} {} grid (@var{hax}, @dots{})
24## Force the display of a grid on the plot.
25## The argument may be either @code{"on"}, or @code{"off"}.
26## If it is omitted, the current grid state is toggled.
28## If @var{arg} is @code{"minor"} then the minor grid is toggled. When
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
33## If the first argument is an axis handle, @var{hax}, operate on the
34## specified axis object.
40function grid (varargin)
42 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:});
44 grid_on = (strcmp (get (ax, "xgrid"), "on")
45 && strcmp (get (ax, "ygrid"), "on")
46 && strcmp (get (ax, "zgrid"), "on"));
48 minor_on = (strcmp (get (ax, "xminorgrid"), "on")
49 && strcmp (get (ax, "yminorgrid"), "on")
50 && strcmp (get (ax, "zminorgrid"), "on"));
59 if (strcmpi (x, "off"))
61 elseif (strcmpi (x, "on"))
63 elseif (strcmpi (x, "minor"))
66 if (strcmpi (x2, "on"))
69 elseif (strcmpi (x2, "off"))
75 minor_on = ! minor_on;
84 error ("grid: argument must be a string");
89 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on");
91 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on");
93 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
96 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off");
97 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
117%! title ("grid minor")
121%! title ("grid minor")