changeset 6607:98724cae69c7

[project @ 2007-05-07 19:57:47 by dbateman]
author dbateman
date Mon, 07 May 2007 19:57:47 +0000
parents 2c19eaa2c6f7
children 2581a3c23f18
files scripts/ChangeLog scripts/sparse/spy.m
diffstat 2 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon May 07 17:09:38 2007 +0000
+++ b/scripts/ChangeLog	Mon May 07 19:57:47 2007 +0000
@@ -1,6 +1,7 @@
 2007-05-07  David Bateman  <dbateman@free.fr>
 
-	* sparse/spy.m: Reverse Y axis for new graphics code.
+	* sparse/spy.m: Reverse Y axis for new graphics code. Make more
+	compatiable, accepting LineSpec and markersize arguments.
 
 2007-05-02  John W. Eaton  <jwe@octave.org>
 
--- a/scripts/sparse/spy.m	Mon May 07 17:09:38 2007 +0000
+++ b/scripts/sparse/spy.m	Mon May 07 19:57:47 2007 +0000
@@ -17,10 +17,32 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} spy (@var{x})
-## Plot the sparsity pattern of the sparse matrix @var{x}.
+## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize})
+## @deftypefnx {Function File} {} spy (@dots{}, @var{LineSpec})
+## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument
+## @var{markersize} is given as an scalar value, it is used to determine the
+## point size in the plot. If the string @var{LineSpec} is given it is
+## passed to @code{plot} and determines the appearance of the plot.
+## @seealso{plot}
 ## @end deftypefn
 
-function spy (S) 
+function spy (S, varargin) 
+
+  markersize = NaN;
+  if (numel (i) < 1000)
+    LineSpec = "*";
+  else
+    LineSpec = ".";
+  endif
+  for i = 1:length(varargin)
+    if (ischar(varargin{i}))
+      LineSpec = varargin{i};
+    elseif (isscalar (varargin{i}))
+      markersize = varargin{i};
+    else
+      error ("spy: expected markersize or linespec");
+    endif
+  endfor
 
   if (issparse (S))
     [i, j, s, m, n] = spfind (S);
@@ -29,10 +51,10 @@
     [m, n] = size (S);
   endif
 
-  if (numel (i) < 1000)
-    plot (j, i, "*");
+  if (isnan (markersize))
+    plot (j, i, LineSpec);
   else
-    plot (j, i, ".");
+    plot (j, i, LineSpec, "MarkerSize", markersize);
   endif
 
   axis ([0, n+1, m+1, 0]);