Mercurial > hg > octave-nkf
annotate scripts/plot/grid.m @ 10509:ddbd812d09aa
properly compress sparse matrices after assembly
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 12 Apr 2010 12:57:44 +0200 |
parents | 6a035159ba0e |
children | 95c3e38098bf |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2003, 2004, |
8920 | 2 ## 2005, 2006, 2007, 2008, 2009 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}) |
8528 | 23 ## @deftypefnx {Function File} {} grid (@var{hax}, @dots{}) |
6257 | 24 ## Force the display of a grid on the plot. |
8528 | 25 ## The argument may be either @code{"on"}, or @code{"off"}. |
26 ## If it is omitted, the current grid state is toggled. | |
5727 | 27 ## |
6895 | 28 ## If @var{arg} is @code{"minor"} then the minor grid is toggled. When |
5727 | 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 | |
6257 | 31 ## the minor grid. |
8528 | 32 ## |
33 ## If the first argument is an axis handle, @var{hax}, operate on the | |
34 ## specified axis object. | |
6895 | 35 ## @seealso{plot} |
3368 | 36 ## @end deftypefn |
4 | 37 |
2314 | 38 ## Author: jwe |
39 | |
7215 | 40 function grid (varargin) |
5727 | 41 |
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
|
42 [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:}); |
6257 | 43 |
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
|
44 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
|
45 && 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
|
46 && 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
|
47 |
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 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
|
49 && 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
|
50 && strcmp (get (ax, "zminorgrid"), "on")); |
7216 | 51 |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
52 if (nargs > 2) |
7215 | 53 print_usage (); |
54 elseif (nargs == 0) | |
55 grid_on = ! grid_on; | |
6257 | 56 else |
7215 | 57 x = varargin{1}; |
5443 | 58 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
|
59 if (strcmpi (x, "off")) |
5727 | 60 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
|
61 elseif (strcmpi (x, "on")) |
5727 | 62 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
|
63 elseif (strcmpi (x, "minor")) |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
64 if (nargs == 2) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
65 x2 = varargin{2}; |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
66 if (strcmpi (x2, "on")) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
67 minor_on = true; |
8507 | 68 grid_on = true; |
8501 | 69 elseif (strcmpi (x2, "off")) |
70 minor_on = false; | |
71 else | |
72 print_usage (); | |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
73 endif |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
74 else |
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
|
75 minor_on = ! minor_on; |
8424
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
76 if (minor_on) |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
77 grid_on = true; |
a84d71abdc5b
grid.m: handle minor grid option
Doug Stewart <dastew@sympatico.ca>
parents:
8190
diff
changeset
|
78 endif |
5727 | 79 endif |
4 | 80 else |
6046 | 81 print_usage (); |
4 | 82 endif |
83 else | |
904 | 84 error ("grid: argument must be a string"); |
4 | 85 endif |
6257 | 86 endif |
87 | |
88 if (grid_on) | |
89 set (ax, "xgrid", "on", "ygrid", "on", "zgrid", "on"); | |
90 if (minor_on) | |
91 set (ax, "xminorgrid", "on", "yminorgrid", "on", "zminorgrid", "on"); | |
5727 | 92 else |
6257 | 93 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); |
94 endif | |
4 | 95 else |
6257 | 96 set (ax, "xgrid", "off", "ygrid", "off", "zgrid", "off"); |
97 set (ax, "xminorgrid", "off", "yminorgrid", "off", "zminorgrid", "off"); | |
5152 | 98 endif |
99 | |
4 | 100 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
|
101 |
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 %!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
|
103 %! 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
|
104 %! 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
|
105 %! 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
|
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 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
|
108 %! 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 %! 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
|
110 %! 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
|
111 %! 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
|
112 %! 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
|
113 %! 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
|
114 %! 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
|
115 %! 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
|
116 %! 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 %! 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
|
118 %! 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
|
119 %! 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
|
120 %! 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 %! 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
|
122 |