2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
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 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
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. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3368
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} grid (@var{arg}) |
|
22 ## For two-dimensional plotting, force the display of a grid on the plot. |
|
23 ## The argument may be either @code{"on"} or @code{"off"}. If it is |
|
24 ## omitted, @code{"on"} is assumed. |
|
25 ## @end deftypefn |
5053
|
26 ## |
3407
|
27 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, |
5214
|
28 ## bar, stairs, replot, xlabel, ylabel, and title} |
4
|
29 |
2314
|
30 ## Author: jwe |
|
31 |
4264
|
32 ## PKG_ADD: mark_as_command grid |
|
33 |
2311
|
34 function grid (x) |
4
|
35 |
3457
|
36 usage_msg = "grid (\"on\" | \"off\")"; |
|
37 |
5152
|
38 do_replot = false; |
|
39 |
4
|
40 if (nargin == 0) |
5252
|
41 __gnuplot_raw__ ("set grid;\n"); |
5152
|
42 do_replot = true; |
4
|
43 elseif (nargin == 1) |
5443
|
44 if (ischar (x)) |
4
|
45 if (strcmp ("off", x)) |
5252
|
46 __gnuplot_raw__ ("set nogrid;\n"); |
5152
|
47 do_replot = true; |
4
|
48 elseif (strcmp ("on", x)) |
5252
|
49 __gnuplot_raw__ ("set grid"); |
5152
|
50 do_replot = true; |
4
|
51 else |
5152
|
52 usage (usage_msg); |
4
|
53 endif |
|
54 else |
904
|
55 error ("grid: argument must be a string"); |
4
|
56 endif |
|
57 else |
3457
|
58 usage (usage_msg); |
4
|
59 endif |
|
60 |
5152
|
61 if (do_replot && automatic_replot) |
5493
|
62 replot (); |
5152
|
63 endif |
|
64 |
4
|
65 endfunction |