plots - Maple Programming Help

Home : Support : Online Help : Graphics : Packages : plots : plots/sparsematrixplot

plots

 sparsematrixplot
 2-D plot of nonzero values of a matrix

 Calling Sequence sparsematrixplot(A, options)

Parameters

 A - Matrix matrixview - BooleanOpt('matrixview') zeros - BooleanOpt('zeros')

Description

 • The sparsematrixplot function defines a two-dimensional graph with the x and y coordinates representing by default the row and column indices, respectively.  If the option matrixview is given, the x and y coordinates represent the column and row indices, with the axes appropriately relabeled.  The drawback of relabeling is that the coordinates of a selected point can no longer be found.
 • By default, sparsematrixplot plots a square for every nonzero entry of the matrix.  It is useful for displaying sparsity patterns of matrices.
 • If the option zeros is specified, the zeros in the matrix are plotted instead of the nonzeros.
 • Remaining arguments are interpreted as options which are specified as equations of the form option = value.  See plot/options for more information.
 • The result of a call to sparsematrixplot is a PLOT structure which can be rendered by the plotting device. The user may assign a PLOT value to a variable, save it in a file, then read it back in for redisplay. See plot/structure.
 • sparsematrixplot may be defined by with(plots) or with(plots,sparsematrixplot). It can also be used by the name plots[sparsematrixplot].

Examples

 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $A≔\mathrm{Matrix}\left(\left[\left[2,1,0,0,3\right],\left[0,2,1,0,0\right],\left[0,0,2,1,0\right],\left[0,0,0,2,1\right],\left[0,0,0,0,2\right]\right]\right)$
 ${A}{≔}\left[\begin{array}{ccccc}{2}& {1}& {0}& {0}& {3}\\ {0}& {2}& {1}& {0}& {0}\\ {0}& {0}& {2}& {1}& {0}\\ {0}& {0}& {0}& {2}& {1}\\ {0}& {0}& {0}& {0}& {2}\end{array}\right]$ (1)
 > $\mathrm{sparsematrixplot}\left(A,\mathrm{matrixview}\right)$
 > $\mathrm{sparsematrixplot}\left(A\right)$

The commands to create the plot from the Plotting Guide are

 > $A≔\mathrm{RandomMatrix}\left(10,10,\mathrm{density}=0.15\right):$
 > $B≔\mathrm{GaussianElimination}\left(A\right):$
 > $\mathrm{PA}≔\mathrm{sparsematrixplot}\left(A,\mathrm{matrixview},\mathrm{color}="Blue"\right):$
 > $\mathrm{PB}≔\mathrm{sparsematrixplot}\left(B,\mathrm{matrixview},\mathrm{color}="Red"\right):$
 > $\mathrm{display}\left(\left\{\mathrm{PA},\mathrm{PB}\right\}\right)$

An example of a sparse (cubic) graph.

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{SpecialGraphs}\left[\mathrm{DodecahedronGraph}\right]\left(\right):$
 > $\mathrm{DrawGraph}\left(G\right)$
 > $A≔\mathrm{AdjacencyMatrix}\left(G\right):$

A[i,j] = A[j,i] = 1 if there is an edge between vertex i and j in the graph G and 0 otherwise.

 > $\mathrm{sparsematrixplot}\left(A,\mathrm{matrixview}\right)$

Compatibility

 • The plots[sparsematrixplot] command was updated in Maple 18.
 • The zeros parameter was introduced in Maple 18.