1 ## Copyright (C) 1998-2012 Andy Adler
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} {} spy (@var{x})
21 ## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize})
22 ## @deftypefnx {Function File} {} spy (@dots{}, @var{line_spec})
23 ## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument
24 ## @var{markersize} is given as a scalar value, it is used to determine the
25 ## point size in the plot. If the string @var{line_spec} is given it is
26 ## passed to @code{plot} and determines the appearance of the plot.
30 function spy (x, varargin)
42 for i = 1:length (varargin)
43 if (ischar (varargin{i}))
44 if (length (varargin{i}) == 1)
45 line_spec = [line_spec, varargin{i}];
47 line_spec = varargin{i};
49 elseif (isscalar (varargin{i}))
50 markersize = varargin{i};
52 error ("spy: expected markersize or linespec");
59 if (isnan (markersize))
60 plot (j, i, line_spec);
62 plot (j, i, line_spec, "markersize", markersize);
65 axis ([0, n+1, 0, m+1], "ij");
72 %! spy (sprand (10,10, 0.2));
74 %% Mark graphical function as tested by demo block