ArrayPlot

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)

Plot an array of numbers:

Give explicit color directives to specify colors for individual cells:

Specify overall color rules:

Include a mesh:

Plot a table of data:

Use a standard blend as a color function:

Scope  (7)

By default, absolute values go from white to black:

Unknown or symbolic values are shown dark red:

Plot data with units:

Specify explicit colors for each cell:

Plot a ragged array, padding on the right:

Cells with value None are rendered like the background:

Plot a sparse array:

Options  (96)

AspectRatio  (2)

Make all cells square:

Use a different aspect ratio:

Axes  (4)

By default, ArrayPlot uses a frame instead of axes:

Use axes instead of a frame:

Use AxesOrigin to specify where the axes intersect:

Turn each axis on individually:

AxesLabel  (3)

No axes labels are drawn by default:

Place a label on the axis:

Specify axes labels:

AxesOrigin  (2)

The position of the axes is determined automatically:

Specify an explicit origin for the axes:

AxesStyle  (4)

Change the style for the axes:

Specify the style of each axis:

Use different styles for the ticks and the axes:

Use different styles for the labels and the axes:

Background  (4)

Background is normally visible only around the edges:

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

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

ClippingStyle overrides background color:

ClippingStyle  (3)

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

Show values outside the plot range in red:

Show low values in blue and high values in red:

ColorFunction  (5)

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

Use a pure function as the color function:

Use a named color gradient from ColorData:

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

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

ColorRules  (6)

Specify color rules for explicit values or patterns:

ColorFunction is used if no color rules apply:

The array can contain symbolic values:

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

Use any patterns in ColorRules:

Rules are used in the order given:

DataReversed  (4)

Reverse the order of rows:

The frame ticks give the original row numbers:

Reverse the order of rows and columns:

Reverse the order of columns:

Epilog  (3)

Use Epilog to superimpose other graphics:

The graphics can be translucent:

Epilog uses the standard Graphics coordinate system:

Frame  (4)

ArrayPlot uses a frame by default:

Use FrameFalse to turn off the frame:

Draw a frame on the left and right edges:

Draw a frame on the left and bottom edges:

FrameLabel  (3)

Place a label along the bottom frame of a plot:

Place labels on each of the edges in the frame:

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

FrameStyle  (2)

Specify the style of the frame:

Specify style for each frame edge:

FrameTicks  (13)

Frame ticks are not included by default:

Use frame ticks on the bottom edge:

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

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

Use FrameTicksAll to include tick labels on all edges:

Place tick marks at specific positions:

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

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

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

Specify a style for each frame tick:

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

Frame ticks without a visible frame:

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

Make the frame invisible:

FrameTicksStyle  (3)

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

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

Use a different style for the different frame edges:

GridLines  (3)

Draw grids across the plot:

Draw grid lines at specified positions:

Specify grid styles:

ImageSize  (7)

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

Specify the width of the plot:

Specify the height of the plot:

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

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

Setting AspectRatioFull will fill the available space:

Use maximum sizes for the width and height:

Use ImageSizeFull to fill the available space in an object:

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

MaxPlotPoints  (1)

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

Mesh  (7)

Insert mesh lines between all cells:

Insert 15 row mesh lines and 5 column mesh lines:

Insert mesh lines around the first 10 columns:

Use a sequence of colors for the mesh lines:

Insert mesh lines after the first and second rows:

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

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

MeshStyle  (2)

Default mesh style:

Make the mesh pink:

PlotLegends  (5)

No legend is used by default:

Generate a legend automatically:

PlotLegends automatically picks up ColorFunction:

Legend uses ColorRules as labels:

Use Placed to place legend outside the plot:

PlotRange  (5)

Plot all elements:

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

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

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

Plot positive elements only:

PlotTheme  (1)

Use a theme with detailed ticks and a legend:

Move the legend below the plot:

Applications  (11)

Plot a two-color cellular automaton evolution:

Plot a three-color cellular automaton evolution:

Use colors rather than gray levels:

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

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

Show positive entries as black and others as yellow:

Create a list of array plots:

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

Plot image-processed data:

Plot a color map:

Use a special color for non-numeric data:

Digits of powers of 3 in base 2:

Plot a sparse matrix in black and white:

Properties & Relations  (8)

An empty array yields a blank picture:

Grid arranges elements the same way as ArrayPlot:

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

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

Use ArrayPlot3D for 3D arrays of data:

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

Or for large sparse matrices:

Use ReliefPlot for medical and geographic data:

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

Use GraphPlot for visualizing adjacency matrices:

Possible Issues  (2)

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

Use MatrixPlot instead (or provide a custom ColorFunction):

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

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

Neat Examples  (2)

Plot the Sin function at integer points:

Interactively map GCD values onto colors using Hue:

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).

CMS

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_arrayplot, organization={Wolfram Research}, title={ArrayPlot}, year={2021}, url={https://reference.wolfram.com/language/ref/ArrayPlot.html}, note=[Accessed: 26-December-2024 ]}