# plot::SparseMatrixplot

Sparsity pattern of a matrix

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```plot::SparseMatrixplot(`A`, `options`)
plot::SparseMatrixplot(`A`, `x = xmin .. xmax`, `y = ymin .. ymax`, <`a = amin .. amax`>, `options`)
plot::SparseMatrixplot(`[row1, row2, …]`, `options`)
plot::SparseMatrixplot(`[row1, row2, …]`, `x = xmin .. xmax`, `y = ymin .. ymax`, <`a = amin .. amax`>, `options`)
```

## Description

`plot::SparseMatrixplot(A)` creates a 2D plot with the axes representing the rows and columns of the matrix A. For each nonzero entry of A a point is plotted, thus displaying sparsity patterns in the matrix.

`plot::SparseMatrixplot` interprets the indices of a matrix as x and y coordinates, respectively. The indices are ordered according to the standard orientation of the axes, i.e., low matrix indices are found in the lower left corner of the plot.

If `x = xmin .. xmax` is specified, the j-th column of an m×n matrix A corresponds to the coordinate .

If `y = ymin .. ymax` is specified, the i-th row corresponds to the coordinate .

If no coordinate range is specified, ```xmin = 1```, `xmax = n`, and ```ymin = 1```, `ymax = m` is used, i.e., the coordinate x = j corresponds to the j-th column, the coordinate y = i corresponds to the i-th row.

A point is plotted for each non-zero matrix entry Aij.

By default, the attribute `PointColorType` = `Flat` is used. The color of all points is given by `PointColor`.

With `PointColorType` = `Dichromatic`, a color blend from `PointColor` to `PointColor2` is used to indicate the size of the non-zero matrix entries. The color of points corresponding to small entries Aij is `PointColor`. Large entries are colored with `PointColor2`.

Animations are triggered by specifying a range ```a = amin .. amax``` for a parameter `a` that is different from the variables `x`, `y`. Thus, in animations, both the ranges ```x = xmin .. xmax```, ```y = ymin .. ymax``` as well as the animation range ```a = amin .. amax``` must be specified.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`TRUE`
`Color`the main color`RGB::MidnightBlue`
`Data`the (statistical) data to plot
`Frames`the number of frames in an animation`50`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointSize`the size of points`1.0`
`PointColor`the color of points`RGB::MidnightBlue`
`PointColor2`secondary point color for color blends`RGB::Red`
`PointStyle`the presentation style of points`Diamonds`
`PointsVisible`visibility of mesh points`TRUE`
`PointColorType`point coloring types`Flat`
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XMax`final value of parameter "x"
`XMin`initial value of parameter "x"
`XName`name of parameter "x"
`XRange`range of parameter "x"
`YMax`final value of parameter "y"
`YMin`initial value of parameter "y"
`YName`name of parameter "y"
`YRange`range of parameter "y"

## Examples

### Example 1

We create a random matrix of dimension 100 ×200 with 1000 nonzero entries:

```A := matrix::random(100, 200, 1000, frandom): plot(plot::SparseMatrixplot(A))```

With `PointColorType` = `Dichromatic`, the color of the points indicates the size of the matrix entries:

`plot(plot::SparseMatrixplot(A, PointColorType = Dichromatic)):`

`delete A:`

### Example 2

Choosing appropriate coordinate ranges, we let two sparse matrix plots overlap each other. The red points correspond to a sparse 10 ×10 matrix with 50 random entries. The blue points indicate the corresponding upper triangular form obtained by Gaussian elimination:

```A := matrix::random(10, 10, 50, random(1..5)): B := A::dom::gaussElim(A)[1]: plot(plot::SparseMatrixplot(A, x = 1..10, y = 1..10, Color = RGB::Red), plot::SparseMatrixplot(B, x = 1.3..10.3, y = 1..10, Color = RGB::Blue, PointStyle = FilledCircles), PointSize = 2*unit::mm, Scaling = Constrained, Axes = Frame)```

`delete A, B:`

## Parameters

 `A` A matrix of category `Cat::Matrix` or an array containing real numerical values or expressions of the animation parameter `a`. `A` is equivalent to the attribute `Data`. `row1, row2, …` The matrix rows: each row must be a list of real numerical values or expressions of the animation parameter `a`. All rows must have the same length. `row1`, `row2`, … is equivalent to the attribute `Data`. `x` Name of the horizontal coordinate: an identifier or an indexed identifier. It is used as the title of the coordinate axis in x direction. `x` is equivalent to the attribute `XName`. `xmin .. xmax` The range of the horizontal coordinate: `xmin`, `xmax` must be numerical real value or expressions of the animation parameter a. `xmin` .. `xmax` is equivalent to the attributes `XRange`, `XMin`, `XMax`. `y` Name of the vertical coordinate: an identifier or an indexed identifier. It is used as the title of the coordinate axis in y direction. `y` is equivalent to the attribute `YName`. `ymin .. ymax` The range of the vertical coordinate: `ymin`, `ymax` must be numerical real value or expressions of the animation parameter a. `ymin` .. `ymax` is equivalent to the attributes `YRange`, `YMin`, `YMax`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.

Get trial now