Mercurial > hg > octave-nkf
annotate scripts/plot/grid.m @ 15536:2e8eb9ac43a5 stable rc-3-6-4-0
3.6.4-rc0 release candidate
* configure.ac (AC_INIT): Version is now 3.6.2-rc0.
(OCTAVE_RELEASE_DATE): Now 2012-05-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Oct 2012 10:05:44 -0400 |
parents | 72c96de7a403 |
children | 11949c9795a0 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1 ## Copyright (C) 1993-2012 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
245 | 18 |
3368 | 19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} grid (@var{arg}) |
5727 | 21 ## @deftypefnx {Function File} {} grid ("minor", @var{arg2}) |
8528 | 22 ## @deftypefnx {Function File} {} grid (@var{hax}, @dots{}) |
6257 | 23 ## Force the display of a grid on the plot. |
8528 | 24 ## The argument may be either @code{"on"}, or @code{"off"}. |
25 ## If it is 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. |
8528 | 31 ## |
32 ## If the first argument is an axis handle, @var{hax}, operate on the | |
33 ## specified axis object. | |
6895 | 34 ## @seealso{plot} |
3368 | 35 ## @end deftypefn |
4 | 36 |
2314 | 37 ## Author: jwe |
38 | |
7215 | 39 function grid (varargin) |
5727 | 40 |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
41 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:}); |
6257 | 42 |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
43 grid_on = (strcmp (get (ax, "xgrid"), "on") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
44 && strcmp (get (ax, "ygrid"), "on") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
45 && strcmp (get (ax, "zgrid"), "on")); |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
46 |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
47 minor_on = (strcmp (get (ax, "xminorgrid"), "on") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
48 && strcmp (get (ax, "yminorgrid"), "on") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
49 && strcmp (get (ax, "zminorgrid"), "on")); |
7216 | 50 |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
51 if (nargs > 2) |
7215 | 52 print_usage (); |
53 elseif (nargs == 0) | |
54 grid_on = ! grid_on; | |
6257 | 55 else |
7215 | 56 x = varargin{1}; |
5443 | 57 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
|
58 if (strcmpi (x, "off")) |
10549 | 59 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
|
60 elseif (strcmpi (x, "on")) |
10549 | 61 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
|
62 elseif (strcmpi (x, "minor")) |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
63 if (nargs == 2) |
10549 | 64 x2 = varargin{2}; |
65 if (strcmpi (x2, "on")) | |
66 minor_on = true; | |
67 grid_on = true; | |
68 elseif (strcmpi (x2, "off")) | |
69 minor_on = false; | |
70 else | |
71 print_usage (); | |
72 endif | |
73 else | |
74 minor_on = ! minor_on; | |
75 if (minor_on) | |
76 grid_on = true; | |
77 endif | |
78 endif | |
4 | 79 else |
10549 | 80 print_usage (); |
4 | 81 endif |
82 else | |
904 | 83 error ("grid: argument must be a string"); |
4 | 84 endif |
6257 | 85 endif |
86 | |
87 if (grid_on) | |
88 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
89 if (minor_on) | |
90 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on"); | |
5727 | 91 else |
6257 | 92 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); |
93 endif | |
4 | 94 else |
6257 | 95 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off"); |
96 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); | |
5152 | 97 endif |
98 | |
4 | 99 endfunction |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
100 |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
101 %!demo |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
102 %! clf |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
103 %! subplot (2,2,1) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
104 %! plot (1:100) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
105 %! grid minor |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
106 %! grid minor |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
107 %! grid |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
108 %! title ("no grid") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
109 %! subplot (2,2,2) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
110 %! plot (1:100) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
111 %! grid |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
112 %! title ("grid on") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
113 %! subplot (2,2,3) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
114 %! plot (1:100) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
115 %! grid minor |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
116 %! title ("grid minor") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
117 %! subplot (2,2,4) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
118 %! semilogy (1:100) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
119 %! grid minor |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
120 %! title ("grid minor") |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
121 |