WOLFRAM

ArrayPlot[array]

generates a plot in which the values in an array are shown in a discrete array of squares.

Details and Options

Examples

open allclose all

Basic Examples  (6)Summary of the most common use cases

Plot an array of numbers:

Out[1]=1

Give explicit color directives to specify colors for individual cells:

Out[1]=1

Specify overall color rules:

Out[1]=1

Include a mesh:

Out[1]=1

Plot a table of data:

Out[1]=1

Use a standard blend as a color function:

Out[1]=1

Scope  (7)Survey of the scope of standard use cases

By default, absolute values go from white to black:

Out[1]=1

Unknown or symbolic values are shown dark red:

Out[1]=1

Plot data with units:

Out[1]=1

Specify explicit colors for each cell:

Out[1]=1

Plot a ragged array, padding on the right:

Out[1]=1

Cells with value None are rendered like the background:

Out[1]=1

Plot a sparse array:

Out[1]=1

Options  (96)Common values & functionality for each option

AspectRatio  (2)

Make all cells square:

Out[1]=1

Use a different aspect ratio:

Out[1]=1

Axes  (4)

By default, ArrayPlot uses a frame instead of axes:

Out[1]=1

Use axes instead of a frame:

Out[1]=1

Use AxesOrigin to specify where the axes intersect:

Out[1]=1

Turn each axis on individually:

Out[1]=1

AxesLabel  (3)

No axes labels are drawn by default:

Out[2]=2

Place a label on the axis:

Out[1]=1

Specify axes labels:

Out[1]=1

AxesOrigin  (2)

The position of the axes is determined automatically:

Out[2]=2

Specify an explicit origin for the axes:

Out[1]=1

AxesStyle  (4)

Change the style for the axes:

Out[5]=5

Specify the style of each axis:

Out[1]=1

Use different styles for the ticks and the axes:

Out[1]=1

Use different styles for the labels and the axes:

Out[1]=1

Background  (4)

Background is normally visible only around the edges:

Out[1]=1

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

Out[1]=1

Background also by default shows through for values outside the plot range:

Out[1]=1

ClippingStyle overrides background color:

Out[1]=1

ClippingStyle  (3)

The default is to show values outside the plot range in the background color:

Out[1]=1

Show values outside the plot range in red:

Out[1]=1

Show low values in blue and high values in red:

Out[1]=1

ColorFunction  (5)

Map values from 0 to 1 onto colors according to Hue:

Out[1]=1

Use a pure function as the color function:

Out[1]=1

Use a named color gradient from ColorData:

Out[1]=1

Show elements with value 1 as black and all others as white:

Out[1]=1

With ColorFunctionScaling->True, the values are first scaled to lie between 0 and 1:

Out[1]=1

ColorRules  (6)

Specify color rules for explicit values or patterns:

Out[1]=1

ColorFunction is used if no color rules apply:

Out[1]=1

The array can contain symbolic values:

Out[1]=1

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

Out[1]=1

Use any patterns in ColorRules:

Out[1]=1

Rules are used in the order given:

Out[1]=1

DataReversed  (4)

Reverse the order of rows:

Out[1]=1

The frame ticks give the original row numbers:

Out[1]=1

Reverse the order of rows and columns:

Out[1]=1

Reverse the order of columns:

Out[1]=1

Epilog  (3)

Use Epilog to superimpose other graphics:

Out[1]=1

The graphics can be translucent:

Out[1]=1

Epilog uses the standard Graphics coordinate system:

Out[1]=1

Frame  (4)

ArrayPlot uses a frame by default:

Out[1]=1

Use FrameFalse to turn off the frame:

Out[1]=1

Draw a frame on the left and right edges:

Out[1]=1

Draw a frame on the left and bottom edges:

Out[1]=1

FrameLabel  (3)

Place a label along the bottom frame of a plot:

Out[1]=1

Place labels on each of the edges in the frame:

Out[1]=1

Use a customized style for both labels and frame tick labels:

Out[1]=1

FrameStyle  (2)

Specify the style of the frame:

Out[3]=3

Specify style for each frame edge:

Out[1]=1

FrameTicks  (13)

Frame ticks are not included by default:

Out[2]=2

Use frame ticks on the bottom edge:

Out[1]=1

By default, none of the edges have either tick marks or tick labels:

Out[1]=1

Use automatic tick placements to include tick labels on all edges:

Out[1]=1

Use FrameTicksAll to include tick labels on all edges:

Out[1]=1

Place tick marks at specific positions:

Out[1]=1

Draw frame tick marks at the specified positions with specific labels:

Out[1]=1

Specify the lengths for tick marks as a fraction of the graphics size:

Out[1]=1

Use different sizes in the positive and negative directions for each tick mark:

Out[2]=2

Specify a style for each frame tick:

Out[1]=1

Construct a function that places frame ticks at the midpoint and extremes of the frame edge:

Out[2]=2

Frame ticks without a visible frame:

Out[1]=1

With a mesh included, Frame->True is required for frame ticks to be drawn:

Out[1]=1

Make the frame invisible:

Out[1]=1

FrameTicksStyle  (3)

By default, the frame ticks and frame tick labels use the same styles as the frame:

Out[2]=2

Specify an overall style for the ticks, including the labels:

Out[1]=1

Use a different style for the different frame edges:

Out[1]=1

GridLines  (3)

Draw grids across the plot:

Out[5]=5

Draw grid lines at specified positions:

Out[1]=1

Specify grid styles:

Out[1]=1

ImageSize  (7)

Use named sizes such as Tiny, Small, Medium and Large:

Out[1]=1

Specify the width of the plot:

Out[1]=1

Specify the height of the plot:

Out[2]=2

Allow the width and height to be up to a certain size:

Out[1]=1

Specify the width and height for a graphic, padding with space if necessary:

Out[1]=1

Setting AspectRatioFull will fill the available space:

Out[2]=2

Use maximum sizes for the width and height:

Out[1]=1

Use ImageSizeFull to fill the available space in an object:

Out[1]=1

Specify the image size as a fraction of the available space:

Out[1]=1

MaxPlotPoints  (1)

Use MaxPlotPoints to limit the number of elements explicitly plotted in each direction:

Out[1]=1
Out[2]=2

Mesh  (7)

Insert mesh lines between all cells:

Out[1]=1

Insert 15 row mesh lines and 5 column mesh lines:

Out[1]=1

Insert mesh lines around the first 10 columns:

Out[1]=1

Use a sequence of colors for the mesh lines:

Out[1]=1

Insert mesh lines after the first and second rows:

Out[1]=1

Use MeshAutomatic to draw mesh for the data in a ragged array:

Out[1]=1

Use Mesh"Nonzero" to draw mesh lines around nonzero cells:

Out[1]=1

MeshStyle  (2)

Default mesh style:

Out[1]=1

Make the mesh pink:

Out[1]=1

PlotLegends  (5)

No legend is used by default:

Out[1]=1

Generate a legend automatically:

Out[1]=1
Out[2]=2

PlotLegends automatically picks up ColorFunction:

Out[1]=1

Legend uses ColorRules as labels:

Out[1]=1

Use Placed to place legend outside the plot:

Out[1]=1
Out[2]=2

PlotRange  (5)

Plot all elements:

Out[1]=1

Plot only elements with values up to 3, leaving the rest white:

Out[1]=1

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

Out[1]=1

With specific plot range {amin,amax}, the colors range from white at amin to black at amax:

Out[1]=1

Plot positive elements only:

Out[1]=1

PlotTheme  (1)

Use a theme with detailed ticks and a legend:

Out[1]=1

Move the legend below the plot:

Out[2]=2

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

Plot a two-color cellular automaton evolution:

Out[1]=1

Plot a three-color cellular automaton evolution:

Out[1]=1

Use colors rather than gray levels:

Out[2]=2

Plot the imaginary parts of a Vandermonde matrix for a discrete Fourier transform:

Out[1]=1

Plot the inverse of a matrix, shading according to absolute value:

Out[1]=1

Show positive entries as black and others as yellow:

Out[2]=2

Create a list of array plots:

Out[1]=1

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

Out[1]=1

Plot image-processed data:

Out[1]=1

Plot a color map:

Out[1]=1

Use a special color for non-numeric data:

Out[1]=1

Digits of powers of 3 in base 2:

Out[1]=1

Plot a sparse matrix in black and white:

Out[2]=2

Properties & Relations  (8)Properties of the function, and connections to other functions

An empty array yields a blank picture:

Out[1]=1

Grid arranges elements the same way as ArrayPlot:

Out[1]=1
Out[2]=2

Raster arranges elements upside down and with colors reversed relative to ArrayPlot:

Out[1]=1

Make the array be shown the same way as in ArrayPlot:

Out[2]=2

Use ArrayPlot3D for 3D arrays of data:

Out[1]=1

Use MatrixPlot when entries have a big range and many different values:

Out[1]=1

Or for large sparse matrices:

Out[2]=2
Out[3]=3

Use ReliefPlot for medical and geographic data:

Out[1]=1

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

Out[1]=1
Out[2]=2

Use GraphPlot for visualizing adjacency matrices:

Out[1]=1

Possible Issues  (2)Common pitfalls and unexpected behavior

ArrayPlot may not be able to distinguish between large numbers of different values:

Out[2]=2

Use MatrixPlot instead (or provide a custom ColorFunction):

Out[3]=3

Entries of very small relative absolute values may not be differentiable from zero:

Out[1]=1

MatrixPlot scales entries so that entries with small relative absolute values can still be seen:

Out[2]=2

Neat Examples  (2)Surprising or curious use cases

Plot the Sin function at integer points:

Out[1]=1

Interactively map GCD values onto colors using Hue:

Out[1]=1
Wolfram Research (2004), ArrayPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPlot.html (updated 2021).
Wolfram Research (2004), ArrayPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPlot.html (updated 2021).

Text

Wolfram Research (2004), ArrayPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPlot.html (updated 2021).

Wolfram Research (2004), ArrayPlot, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayPlot.html (updated 2021).

CMS

Wolfram Language. 2004. "ArrayPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ArrayPlot.html.

Wolfram Language. 2004. "ArrayPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ArrayPlot.html.

APA

Wolfram Language. (2004). ArrayPlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayPlot.html

Wolfram Language. (2004). ArrayPlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayPlot.html

BibTeX

@misc{reference.wolfram_2025_arrayplot, author="Wolfram Research", title="{ArrayPlot}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayPlot.html}", note=[Accessed: 01-April-2025 ]}

@misc{reference.wolfram_2025_arrayplot, author="Wolfram Research", title="{ArrayPlot}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayPlot.html}", note=[Accessed: 01-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_arrayplot, organization={Wolfram Research}, title={ArrayPlot}, year={2021}, url={https://reference.wolfram.com/language/ref/ArrayPlot.html}, note=[Accessed: 01-April-2025 ]}

@online{reference.wolfram_2025_arrayplot, organization={Wolfram Research}, title={ArrayPlot}, year={2021}, url={https://reference.wolfram.com/language/ref/ArrayPlot.html}, note=[Accessed: 01-April-2025 ]}