This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

ArrayPlot

Updated In 6 Graphic
ArrayPlot[array]
generates a plot in which the values in an array are shown in a discrete array of squares.
  • ArrayPlot[array] by default arranges successive rows of array down the page, and successive columns across, just as a table or grid would normally be formatted.  »
  • If array contains 0s and 1s, the 1s will appear as black squares and the 0s as white squares.
  • ArrayPlot by default generates grayscale output, in which zero values are shown white, and the maximum positive or negative value is shown black.  »
  • With an explicit setting for PlotRange, ArrayPlot by default makes the minimum value white and the maximum black.
  • The following special entries can be used:  »
Nonebackground color
color directivespecified color
  • If array is ragged, shorter rows are treated as padded on the right with background.  »
  • ArrayPlot has the same options as Graphics, with the following additions and changes:
AspectRatioAutomaticratio of height to width
ClippingStyleNonehow to show cells whose values are clipped
ColorFunctionAutomatichow each cell should be colored
ColorFunctionScalingTruewhether to scale the argument to ColorFunction
ColorRulesAutomaticrules for determining colors from values
DataRangeAllthe range of x and y values to assume
DataReversedFalsewhether to reverse the order of rows
FrameAutomaticwhether to draw a frame around the plot
FrameLabelNonelabels for rows and columns
FrameTicksNonewhat ticks to include on the frame
MaxPlotPointsInfinitythe maximum number of points to include
MeshFalsewhether to draw a mesh
MeshStyleGrayLevel[GoldenRatio-1]the style to use for a mesh
PixelConstrainedFalsehow to constrain cells to align with pixels
PlotRangeAllthe range of values to plot
PlotRangeClippingTruewhether to clip at the plot range
  • The rules given by ColorRules are applied to the value a_(i​j) of each cell. The rules can involve patterns.  »
  • If the color determined for a particular cell is None, the cell is rendered in the background color.
  • If no color is determined for a particular cell, the cell is rendered in a default dark red color.
  • With DataReversed->True, the order of rows is reversed, so that rows run from bottom to top, with the last row at the top.
  • With the setting FrameTicks->All, ticks are also placed at the minimum and maximum i and j.  »
  • In explicit FrameTicks specifications, the tick coordinates are taken to refer to i and j.
  • PlotRange->amax specifies that only those a_(i​j) between 0 and amax should be shown.  »
  • PlotRange->{amin, amax} specifies that a_(i​j) between amin and amax should be shown.
  • PlotRange->{{imin, imax}, {jmin, jmax}} shows only elements with i and j in the specified ranges. The top-left element has i=1, j=1. With the default setting DataReversed->False, i increases down the page; j increases to the right.
  • PlotRange->{ispec, jspec, aspec} shows only elements in the specified ranges of i, j and value.  »
  • With the default setting for ColorFunction, PlotRange->{amin, amax} specifies that values from amin to amax should be shown with grayscales varying from white to black.
  • Mesh->True draws mesh lines between each cell in the array.
  • Mesh->{mi, mj} gives mesh specifications for the i and j directions, respectively.
  • For purposes of combining with other graphics, the array element a_(i​j) is taken to cover a unit square centered at coordinate position x=j-1/2, y=i_(max)-i+1/2.
  • A setting DataRange->{{xmin, xmax}, {ymin, ymax}} specifies that the centers of successive cells should be at equally spaced positions between xmin and xmax in the horizontal direction, and ymin and ymax in the vertical direction. With the default setting DataReversed->False, a_(11) is centered at {xmin, ymax}.
  • With the default setting DataRange->All, and DataReversed->False, the array element a_(i​j) will be taken to cover a unit square centered at coordinate position x=j-1/2, y=i_(max)-i+1/2.
  • With PixelConstrained->True, ArrayPlot generates a Raster with an absolute size that aligns cells with pixels, so that each cell is an integer number of pixels across, or each pixel is an integer number of cells across. The cells are each taken to be as large as possible given the ImageSize setting specified.  »
Plot an array of numbers:
In[1]:=
Click for copyable input
Out[1]=
 
Give explicit color directives to specify colors for individual cells:
In[1]:=
Click for copyable input
Out[1]=
 
Specify overall color rules:
In[1]:=
Click for copyable input
Out[1]=
 
Include a mesh:
In[1]:=
Click for copyable input
Out[1]=
 
Plot a table of data:
In[1]:=
Click for copyable input
Out[1]=
 
Use a standard blend as a color function:
In[1]:=
Click for copyable input
Out[1]=
New in 5.1 | Last modified in 6