Other Tools

All plots in this document were produced with the spy module.

The spy Module

Plot the sparsity pattern of a sparse matrix.

Functions Available

pyorder.tools.spy.spy(A, patternonly=True, **kwargs)

To plot the sparsity pattern of a sparse matrix object. The sparse matrix object must implement find(), which must return the contents of the matrix in coordinate format, i.e., (val,irow,jcol).

Parameters:
A:Input matrix
patternonly:If True, only output a black and white sparsity pattern. If False, colorize the plot according to the magnitude of the nonzero elements.
Keywords:
ax:A Pylab Axes instance used to plot the sparsity pattern. If none is given, this function returns an Axes instance.
title:String to be used as title for the plot. If none is given, the title defaults to giving the order of the matrix and the number of nonzero elements.
comment:Comment to be appended to the default plot title in case no title is supplied.
showtitle:Show or hide plot title.
pyorder.tools.spy.FastSpy(nrow, ncol, irow, jcol, **kwargs)

To plot the sparsity pattern of a sparse matrix in coordinate format.

Parameters:
nrow:Number of rows of the matrix.
ncol:Number of columns of the matrix.
irow:Integer Numpy array of length nnz giving the row indices of the nonzero elements.
jcol:Integer Numpy array of length nnz giving the column indices of the nonzero elements.
Keywords:
ax:A Pylab Axes instance used to plot the sparsity pattern. If none is given, this function returns an Axes instance.
sym:Should be set to True if the matrix is symmetric and only one triangle is passed in (irow,jcol).
title:String to be used as title for the plot. If none is given, the title defaults to giving the order of the matrix and the number of nonzero elements.
comment:Comment to be appended to the default plot title in case no title is supplied.
showtitle:Show or hide plot title.
val:Float Numpy array of length nnz giving the values of the nonzero elements of the matrix. If supplied, a scatter plot is produced with patches of size proportional to the magnitude of the element. This option can slow down the plot for large values of the number of nonzero elements.