# `plot`::`Matrixplot`

Surface plot of matrix data

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

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

## Description

`plot::Matrixplot(A)` visualizes the matrix A as a 3D function graph by interpolating the matrix values as a function of the matrix indices.

`Matrixplot` interprets the indices of a matrix as x and y coordinates and the corresponding matrix entry as the corresponding z coordinate. Thus, the matrix is regarded as a discretized function in 2 variables. The function graph is displayed as a 3D surface using interpolation between the data points.

If no ranges `x = `x_{min}` .. `x_{max}``, ```y = `y_{min}` .. `y_{max}```` are specified, the matrix entry ```A[i, j]``` is diplayed as the 3D point x = j, y = i, z = ```A[i, j]``` with integer positions i, j. If plot ranges are specified, the matrix indices i, j are used to define an equidistant mesh in the plot range.

The attribute `InterpolationStyle` allows to define the surface via linear or cubic spline interpolation of the data points: Choose between `InterpolationStyle` = `Linear` or `InterpolationStyle` = `Cubic`. The default is linear interpolation. With cubic interpolation, the data surface may be smoothened by setting the numbers ```mx, my``` of plot points between the data points via the attribute `Submesh` = ```[mx, my]```. The numbers `mx`, `my` must be (small) non-negative integers.

With `InterpolationStyle` = `Linear`, symbolic values and complex numbers are accepted and ignored, leading to gaps in the surface. With `InterpolationStyle` = `Cubic`, symbolic values or complex numbers lead to an error. Cf. Example 4.

Per default, the data points are rendered on the surface. Use `PointsVisible` = `FALSE` to make them disappear.

Animations are triggered by specifying a range ```a = `a_{min}` .. `a_{max}```` for a parameter `a` that is different from the variables `x`, `y`. Thus, in animations, both the ranges `x = `x_{min}` .. `x_{max}``, ```y = `y_{min}` .. `y_{max}```` as well as the animation range ```a = `a_{min}` .. `a_{max}```` must be specified.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`Color`the main color`RGB::Red`
`Data`the (statistical) data to plot
`Filled`filled or transparent areas and surfaces`TRUE`
`FillColor`color of areas and surfaces`RGB::Red`
`FillColor2`second color of areas and surfaces for color blends`RGB::CornflowerBlue`
`FillColorType`surface filling types`Dichromatic`
`FillColorFunction`functional area/surface coloring
`FillColorDirection`the direction of color transitions on surfaces[`0`, `0`, `1`]
`FillColorDirectionX`x-component of the direction of color transitions on surfaces`0`
`FillColorDirectionY`y-component of the direction of color transitions on surfaces`0`
`FillColorDirectionZ`z-component of the direction of color transitions on surfaces`1`
`Frames`the number of frames in an animation`50`
`InterpolationStyle`interpolation via linear or cubic splines`Linear`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Black.[0.25]`
`LineWidth`width of lines`0.35`
`LineColor2`color of lines`RGB::DeepPink`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LineColorType`line coloring types`Flat`
`LineColorFunction`functional line coloring
`LineColorDirection`the direction of color transitions on lines[`0`, `0`, `1`]
`LineColorDirectionX`x-component of the direction of color transitions on lines`0`
`LineColorDirectionY`y-component of the direction of color transitions on lines`0`
`LineColorDirectionZ`z-component of the direction of color transitions on lines`1`
`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.5`
`PointColor`the color of points`RGB::MidnightBlue`
`PointStyle`the presentation style of points`FilledCircles`
`PointsVisible`visibility of mesh points`TRUE`
`Shading`smooth color blend of surfaces`Smooth`
`Submesh`density of submesh (additional sample points)[`2`, `2`]
`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
`TitlePositionZ`position of object titles, z 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`
`XLinesVisible`visibility of parameter lines (x lines)`TRUE`
`XMax`final value of parameter “x”
`XMin`initial value of parameter “x”
`XName`name of parameter “x”
`XRange`range of parameter “x”
`XSubmesh`density of additional sample points for parameter “x”`2`
`YLinesVisible`visibility of parameter lines (y lines)`TRUE`
`YMax`final value of parameter “y”
`YMin`initial value of parameter “y”
`YName`name of parameter “y”
`YRange`range of parameter “y”
`YSubmesh`density of additional sample points for parameter “y”`2`

## Examples

### Example 1

This example demonstrates the general calling syntax. The data are passed in different ways using a list of rows, an array, and a matrix, respectively:

```A := [[2, 1, 1], [3, 4, 3], [3, 5, 4], [2, 6, 5]]: plot(plot::Matrixplot(A))``` With `InterpolationStyle` = `Cubic`, the matrix data are plotted as a cubic spline surface:

```A := array(1..4, 1..3, A): plot(plot::Matrixplot(A, InterpolationStyle = Cubic)):``` The spline surface can be smoothened by using the `Submesh` attribute to add further evaluation points:

```A := matrix(A): plot(plot::Matrixplot(A, Submesh = [6, 6], InterpolationStyle = Cubic)):``` `delete A:`

### Example 2

Various plot attributes can be specified:

```plot(plot::Matrixplot( [[-0.5, 0.5, 0.7, 0.5, -1 ], [ 1.2, 1.3, 1.4, 1.4, 1 ], [ 1.4, 1.5, 1.6, 1.5, 1.2], [ 0.6, 0.8, 1, 1, 1 ], [-0.7, 0.5, 0.5, 0, -1 ]], PointsVisible = FALSE, FillColor = RGB::Green, LineColor = RGB::Red))``` ### Example 3

Choosing appropriate coordinate ranges, we place two matrix plots side by side:

```plot(plot::Matrixplot(matrix::random(5, 5, frandom), x = 0..1, y = 0..1, Color = RGB::Red), plot::Matrixplot(matrix::random(6, 6, frandom), x = 2..3, y = 0..1, Color = RGB::Green), Scaling = Constrained)``` ### Example 4

We plot a Hilbert matrix:

```A := linalg::hilbert(10): plot(plot::Matrixplot(A), CameraDirection = [3, 2, 1])``` Some of the entries are replaced by values that cannot be plotted. Consequently, the plot contains holes:

```A[2, 2] := NIL: A[4, 5] := infinity: A[5, 5] := x: plot(plot::Matrixplot(A), CameraDirection = [3, 2, 1])``` With `InterpolationStyle` = `Cubic`, an error is raised:

`plot(plot::Matrixplot(A, InterpolationStyle = Cubic))`
```Error: Data contains nonreal numeric values. Use 'Style = Linear' to plot matrices containing such data. [plot::Matrixplot::doPlotStatic] Evaluating: plot ```
`delete A:`

## 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`. `s` A data sample of domain type `stats::sample`. `s` is equivalent to the attribute `Data`. `c1, c2, …` Column indices of `s`: positive integers. These indices, if given, indicate that only the specified columns should be used. The indexed columns must contain real numerical values or expressions of the animation parameter `a`, If no columns are specified, all columns of `s` are used. `x` Name of the first 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 first 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 second 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 second 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.