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:
  • ClippingStyleAutomatichow to show clipped values
    FrameTruewhether to draw a frame around the plot
    FrameTicksAllwhat ticks to include on the frame
    MaxPlotPointsAutomaticthe 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.


open all close all

Basic Examples  (4)

Plot a matrix as an array of colors:

Click for copyable input

Plot a matrix using only black and white:

Click for copyable input

Plot the structure of dense matrices:

Click for copyable input

Plot the structure of sparse matrices:

Click for copyable input
Click for copyable input

Scope  (19)

Options  (39)

Applications  (3)

Properties & Relations  (5)

Possible Issues  (2)

Neat Examples  (1)

Introduced in 2007
Updated in 2014