1 ## Copyright (C) 1993-2012 John W. Eaton
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @deftypefn {Function File} {} grid (@var{arg})
21 ## @deftypefnx {Function File} {} grid ("minor", @var{arg2})
22 ## @deftypefnx {Function File} {} grid (@var{hax}, @dots{})
23 ## Force the display of a grid on the plot.
24 ## The argument may be either @code{"on"}, or @code{"off"}.
25 ## If it is omitted, the current grid state is toggled.
27 ## If @var{arg} is @code{"minor"} then the minor grid is toggled. When
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
32 ## If the first argument is an axis handle, @var{hax}, operate on the
33 ## specified axis object.
39 function grid (varargin)
41 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:});
43 grid_on = (strcmp (get (ax, "xgrid"), "on")
44 && strcmp (get (ax, "ygrid"), "on")
45 && strcmp (get (ax, "zgrid"), "on"));
47 minor_on = (strcmp (get (ax, "xminorgrid"), "on")
48 && strcmp (get (ax, "yminorgrid"), "on")
49 && strcmp (get (ax, "zminorgrid"), "on"));
58 if (strcmpi (x, "off"))
60 elseif (strcmpi (x, "on"))
62 elseif (strcmpi (x, "minor"))
65 if (strcmpi (x2, "on"))
68 elseif (strcmpi (x2, "off"))
74 minor_on = ! minor_on;
83 error ("grid: argument must be a string");
88 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on");
90 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on");
92 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
95 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off");
96 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off");
116 %! title ("grid minor")
120 %! title ("grid minor")