# plot::Matrixplot

Surface plot of matrix data

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## 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
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Colorthe main colorRGB::Red
Datathe (statistical) data to plot
Filledfilled or transparent areas and surfacesTRUE
FillColorcolor of areas and surfacesRGB::Red
FillColor2second color of areas and surfaces for color blendsRGB::CornflowerBlue
FillColorTypesurface filling typesDichromatic
FillColorFunctionfunctional area/surface coloring
FillColorDirectionthe direction of color transitions on surfaces[0, 0, 1]
FillColorDirectionXx-component of the direction of color transitions on surfaces0
FillColorDirectionYy-component of the direction of color transitions on surfaces0
FillColorDirectionZz-component of the direction of color transitions on surfaces1
Framesthe number of frames in an animation50
InterpolationStyleinterpolation via linear or cubic splinesLinear
Legendmakes a legend entry
LegendTextshort explanatory text for legend
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Black.[0.25]
LineWidthwidth of lines0.35
LineColor2color of linesRGB::DeepPink
LineStylesolid, dashed or dotted lines?Solid
LineColorTypeline coloring typesFlat
LineColorFunctionfunctional line coloring
LineColorDirectionthe direction of color transitions on lines[0, 0, 1]
LineColorDirectionXx-component of the direction of color transitions on lines0
LineColorDirectionYy-component of the direction of color transitions on lines0
LineColorDirectionZz-component of the direction of color transitions on lines1
Namethe name of a plot object (for browser and legend)
ParameterEndend value of the animation parameter
ParameterNamename of the animation parameter
ParameterBegininitial value of the animation parameter
ParameterRangerange of the animation parameter
PointSizethe size of points1.5
PointColorthe color of pointsRGB::MidnightBlue
PointStylethe presentation style of pointsFilledCircles
PointsVisiblevisibility of mesh pointsTRUE
Submeshdensity of submesh (additional sample points)[2, 2]
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component
TitlePositionYposition of object titles, y component
TitlePositionZposition of object titles, z component
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value
VisibleBeforeobject visible until this time value
VisibleFromToobject visible during this time range
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XLinesVisiblevisibility of parameter lines (x lines)TRUE
XMaxfinal value of parameter "x"
XMininitial value of parameter "x"
XNamename of parameter "x"
XRangerange of parameter "x"
XSubmeshdensity of additional sample points for parameter "x"2
YLinesVisiblevisibility of parameter lines (y lines)TRUE
YMaxfinal value of parameter "y"
YMininitial value of parameter "y"
YNamename of parameter "y"
YRangerange of parameter "y"
YSubmeshdensity 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.