MatrixPlot
✖
MatrixPlot
generates a plot that gives a visual representation of the values of elements in a matrix.
Details and Options

- MatrixPlot[m] by default arranges successive rows of m down the page and successive columns across, just as a matrix would normally be formatted.
- MatrixPlot by default displays zero values as white, with negative values tending to be bluish and positive values reddish.
- MatrixPlot has the same options as ArrayPlot, with the following changes: [List of all options]
-
ClippingStyle Automatic how to show clipped values Frame True whether to draw a frame around the plot FrameTicks All what ticks to include on the frame MaxPlotPoints Automatic the maximum number of points to include - PlotRange->r specifies that only those aij between -r and +r should be shown.
- With the default setting ColorFunctionScaling->True, scaling is done based on a mixture of relative value and ranking for each matrix element. The final scaled value always lies between 0 and 1, with scaled value 0.5 corresponding to matrix element value 0.
- With the default setting MaxPlotPoints->Automatic, sufficiently large or sparse matrices are downsampled so that their structure is visible in the plot generated by MatrixPlot.
- MatrixPlot works with SparseArray objects.
-
AlignmentPoint Center the default point in the graphic to align with AspectRatio Automatic ratio of height to width Axes False whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ClippingStyle Automatic how to show clipped values ColorFunction Automatic how each cell should be colored ColorFunctionScaling True whether to scale the argument to ColorFunction ColorRules Automatic rules for determining colors from values ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool DataRange All the range of and
values to assume
DataReversed False whether to reverse the order of rows Epilog {} primitives rendered after the main plot FormatType TraditionalForm the default format type for text Frame True whether to draw a frame around the plot FrameLabel None labels for rows and columns FrameStyle {} style specifications for the frame FrameTicks All what ticks to include on the frame FrameTicksStyle {} style specifications for frame ticks GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic LabelStyle {} style specifications for labels MaxPlotPoints Automatic the maximum number of points to include Mesh False whether to draw a mesh MeshStyle GrayLevel[GoldenRatio-1] the style to use for a mesh Method Automatic details of graphics methods to use PlotLabel None an overall label for the plot PlotLegends None legends for datasets PlotRange All the range of values to plot PlotRangeClipping False whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotTheme $PlotTheme overall theme for the plot PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RotateLabel True whether to rotate y labels on the frame TargetUnits Automatic units to display in the plot Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks
List of all options



Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Plot a matrix as an array of colors:

https://wolfram.com/xid/0e7mnp3m-cz20m9

Plot a matrix using only black and white:

https://wolfram.com/xid/0e7mnp3m-rxrqwc

Plot the structure of dense matrices:

https://wolfram.com/xid/0e7mnp3m-bskhde

Plot the structure of sparse matrices:

https://wolfram.com/xid/0e7mnp3m-xo05r


https://wolfram.com/xid/0e7mnp3m-cq9ipw

Scope (19)Survey of the scope of standard use cases
Data (10)

https://wolfram.com/xid/0e7mnp3m-9fvce

https://wolfram.com/xid/0e7mnp3m-vt9seo


https://wolfram.com/xid/0e7mnp3m-1yep1o


https://wolfram.com/xid/0e7mnp3m-z44aj3

Plot a nonrectangular "matrix", with missing entries transparent:

https://wolfram.com/xid/0e7mnp3m-85vhm

Negative entries are shown in cool colors, positive entries in warm colors, and zeros in white:

https://wolfram.com/xid/0e7mnp3m-msw6el

Entries near zero are shown in a shade of gray; entries very close to zero may be shown in white:

https://wolfram.com/xid/0e7mnp3m-sqx1j9

Complex numbers are shown based on their real parts:

https://wolfram.com/xid/0e7mnp3m-fot9aj

None is interpreted as a missing value and displayed using transparency:

https://wolfram.com/xid/0e7mnp3m-ie3c0k

Symbolic values other than None are shown in dark red:

https://wolfram.com/xid/0e7mnp3m-g5ibda

Colors are shown darker for very sparse matrices to make entries more visible:

https://wolfram.com/xid/0e7mnp3m-nd658i

Show a matrix with irrational and arbitrary-precision entries:

https://wolfram.com/xid/0e7mnp3m-7mlack

Presentation (9)

https://wolfram.com/xid/0e7mnp3m-c6pngv

https://wolfram.com/xid/0e7mnp3m-1bye

Give explicit color directives to specify colors for individual cells:

https://wolfram.com/xid/0e7mnp3m-cruw4j


https://wolfram.com/xid/0e7mnp3m-dkvqu1

Use a black-and-white color function to highlight the sparse structure of a matrix:

https://wolfram.com/xid/0e7mnp3m-w2nb4f


https://wolfram.com/xid/0e7mnp3m-ndoz45

Use a custom color function with blue colors for negative values and red colors for positive values:

https://wolfram.com/xid/0e7mnp3m-n61dgh

Use ColorRules to color different values:

https://wolfram.com/xid/0e7mnp3m-ets82i

Use both ColorRules and ColorFunction to color elements, giving priority to ColorRules:

https://wolfram.com/xid/0e7mnp3m-s1mmj

Use Mesh and MeshStyle to provide an overlay mesh:

https://wolfram.com/xid/0e7mnp3m-m8l29q


https://wolfram.com/xid/0e7mnp3m-gnzx5m

Options (33)Common values & functionality for each option
AspectRatio (2)
Background (2)
Background is normally visible only around the edges:

https://wolfram.com/xid/0e7mnp3m-e3n

The background "shows through" whenever an explicit entry is None:

https://wolfram.com/xid/0e7mnp3m-sro

ClippingStyle (3)
By default, the clipped values are colored vibrant red and blue:

https://wolfram.com/xid/0e7mnp3m-8q467t

Use explicit colors for the clipped values:

https://wolfram.com/xid/0e7mnp3m-sycgt0

Use None to indicate no style, showing the background in those cells:

https://wolfram.com/xid/0e7mnp3m-cjbikl

ColorFunction (5)
Use an explicit color function:

https://wolfram.com/xid/0e7mnp3m-bgq

Use a pure function as the color function:

https://wolfram.com/xid/0e7mnp3m-cbgxu7

Use a named color gradient from ColorData:

https://wolfram.com/xid/0e7mnp3m-e94xrd

If the color function is undefined for some value, then a dark red is substituted:

https://wolfram.com/xid/0e7mnp3m-div4zk

In this case, the color is defined for all the values:

https://wolfram.com/xid/0e7mnp3m-c4epcr

For complex matrices, the real part is used for the color function:

https://wolfram.com/xid/0e7mnp3m-eifaqr


https://wolfram.com/xid/0e7mnp3m-kiypze

ColorFunctionScaling (4)
By default, a nonlinear scaling of entries is used to differentiate values over a wide range:

https://wolfram.com/xid/0e7mnp3m-5m7d9l

With ColorFunctionScaling->False, entries are not scaled:

https://wolfram.com/xid/0e7mnp3m-imx

With ColorFunctionScaling->False, MatrixPlot behaves like ArrayPlot:

https://wolfram.com/xid/0e7mnp3m-oxsh5b


https://wolfram.com/xid/0e7mnp3m-kthb4b

ColorFunctionScaling has no effect on ColorRules:

https://wolfram.com/xid/0e7mnp3m-ls6klj

ColorRules (6)
Specify color rules for explicit values or patterns:

https://wolfram.com/xid/0e7mnp3m-imy

Implement a "default color" by adding a rule for _:

https://wolfram.com/xid/0e7mnp3m-qux

The array can contain symbolic values:

https://wolfram.com/xid/0e7mnp3m-t3w

Use any patterns in ColorRules:

https://wolfram.com/xid/0e7mnp3m-otf

Rules are used in the order given:

https://wolfram.com/xid/0e7mnp3m-qid

ColorRules can be used together with ColorFunction and has higher priority:

https://wolfram.com/xid/0e7mnp3m-cd6

DataReversed (1)
MaxPlotPoints (1)
By default, automatic methods are used to downsample large and/or sparse matrices:

https://wolfram.com/xid/0e7mnp3m-2mo0j


https://wolfram.com/xid/0e7mnp3m-os8e6u

Without downsampling, the entries are less visible:

https://wolfram.com/xid/0e7mnp3m-x96oyq

Explicitly set downsampling values for MaxPlotPoints:

https://wolfram.com/xid/0e7mnp3m-gwe2sl

The visual appearance in the resulting plot is also affected by the choice of ColorFunction:

https://wolfram.com/xid/0e7mnp3m-o12bmi

Mesh (3)
Insert mesh lines between all cells:

https://wolfram.com/xid/0e7mnp3m-c3b

Insert 19 row mesh lines and 1 column mesh line:

https://wolfram.com/xid/0e7mnp3m-vzs

Use a sequence of colors for the mesh lines:

https://wolfram.com/xid/0e7mnp3m-oll

PlotRange (3)

https://wolfram.com/xid/0e7mnp3m-dx7

Plot only elements with values from 0 to 1; clip the rest:

https://wolfram.com/xid/0e7mnp3m-gfo

The first two entries in PlotRange specify the range of rows and columns to include:

https://wolfram.com/xid/0e7mnp3m-kgc

Applications (3)Sample problems that can be solved with this function

https://wolfram.com/xid/0e7mnp3m-ggh8pd


https://wolfram.com/xid/0e7mnp3m-l4c84f

Zoom in to the top-left diagonal block:

https://wolfram.com/xid/0e7mnp3m-ukuehz

Plot the imaginary parts of a discrete Fourier transform matrix:

https://wolfram.com/xid/0e7mnp3m-y30

Plot a table of values of five sine waves in random directions:

https://wolfram.com/xid/0e7mnp3m-k18zdm

Properties & Relations (6)Properties of the function, and connections to other functions
MatrixPlot colors negative entries with cool colors and positive entries with warm colors:

https://wolfram.com/xid/0e7mnp3m-2k5mom

ArrayPlot uses gray scale:

https://wolfram.com/xid/0e7mnp3m-txcos8

MatrixPlot rescales the matrix entries to differentiate values over a wide range:

https://wolfram.com/xid/0e7mnp3m-ggpzp2

Without rescaling, fewer elements can be differentiated:

https://wolfram.com/xid/0e7mnp3m-db5f3j

Use ReliefPlot for medical and geographic data:

https://wolfram.com/xid/0e7mnp3m-yy9gks

Use ListDensityPlot for structured or unstructured data sampled from continuous densities:

https://wolfram.com/xid/0e7mnp3m-c3o2zs

Use ArrayPlot3D for 3D arrays of data:

https://wolfram.com/xid/0e7mnp3m-1rvqxy

Use GraphPlot for visualizing adjacency matrices:

https://wolfram.com/xid/0e7mnp3m-ebepe8

Possible Issues (2)Common pitfalls and unexpected behavior
Using MaxPlotPoints may result in artifacts not actually present in the original data:

https://wolfram.com/xid/0e7mnp3m-od748o

https://wolfram.com/xid/0e7mnp3m-ka59sl

With a small MaxPlotPoints option value, all entries become nonzero:

https://wolfram.com/xid/0e7mnp3m-5q9l5c

Entries very close to zero may be treated as zero:

https://wolfram.com/xid/0e7mnp3m-r9fy8a

Neat Examples (1)Surprising or curious use cases
Wolfram Research (2007), MatrixPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixPlot.html (updated 2014).
Text
Wolfram Research (2007), MatrixPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixPlot.html (updated 2014).
Wolfram Research (2007), MatrixPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixPlot.html (updated 2014).
CMS
Wolfram Language. 2007. "MatrixPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/MatrixPlot.html.
Wolfram Language. 2007. "MatrixPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/MatrixPlot.html.
APA
Wolfram Language. (2007). MatrixPlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MatrixPlot.html
Wolfram Language. (2007). MatrixPlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MatrixPlot.html
BibTeX
@misc{reference.wolfram_2025_matrixplot, author="Wolfram Research", title="{MatrixPlot}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/MatrixPlot.html}", note=[Accessed: 28-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_matrixplot, organization={Wolfram Research}, title={MatrixPlot}, year={2014}, url={https://reference.wolfram.com/language/ref/MatrixPlot.html}, note=[Accessed: 28-March-2025
]}