GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • WOLFRAM
  • Products
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App
  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs
  • Wolfram AI Ecosystem

This view

  • Original page
  • New address

GeezerVison is showing reference.wolfram.com — ArrayPlot: Visualize a 2D sparse array using grayscale or other color maps—Wolfram Documentation

ArrayPlot[array]

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

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
AspectRatio  
Axes  
AxesLabel  
Show More Show More
AxesOrigin  
AxesStyle  
Background  
ClippingStyle  
ColorFunction  
ColorRules  
DataReversed  
Epilog  
Frame  
FrameLabel  
FrameStyle  
FrameTicks  
FrameTicksStyle  
GridLines  
ImageSize  
MaxPlotPoints  
Mesh  
MeshStyle  
PlotLegends  
PlotRange  
PlotTheme  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
Related Links
History
Cite this Page

ArrayPlot

ArrayPlot[array]

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

Details and Options

  • 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 values in array can be quantities with units associated with them.
  • 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: [List of all options]
  • AspectRatio Automaticratio of height to width
    ClippingStyle Nonehow to show cells whose values are clipped
    ColorFunction Automatichow each cell should be colored
    ColorFunctionScaling Truewhether to scale the argument to ColorFunction
    ColorRules Automaticrules for determining colors from values
    DataRangeAllthe range of and values to assume
    DataReversed Falsewhether to reverse the order of rows
    Frame Automaticwhether to draw a frame around the plot
    FrameLabel Nonelabels for rows and columns
    FrameTicks Nonewhat ticks to include on the frame
    MaxPlotPoints Infinitythe maximum number of points to include
    Mesh Falsewhether to draw a mesh
    MeshStyle GrayLevel[GoldenRatio-1]the style to use for a mesh
    PlotLegends Nonelegends for datasets
    PlotRange Allthe range of values to plot
    PlotTheme $PlotThemeoverall theme for the plot
    TargetUnitsAutomaticunits to display in the plot
  • ColorRules can take the following settings:
  • Automaticuse default colors
    "Colors"use colors for different values
    "Monochrome"use grayscale colors
    {valcolor,…}use color as the style for val
  • The rules given by ColorRules are applied to the value of each cell. The rules can involve patterns. »
  • If none of the rules in ColorRules apply, then ColorFunction is used to determine the color.
  • With the default setting ColorRules->Automatic, an explicit setting ColorFunction->f is used instead of ColorRules.
  • With ColorFunctionScaling->False, each value is supplied as the argument to any function given for ColorFunction. »
  • With ColorFunctionScaling->True, the values are scaled to lie between 0 and 1. »
  • 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->Automatic, ticks are placed at round integers, typically multiples of 5 or 10.
  • With the setting FrameTicks->All, ticks are also placed at the minimum and maximum and .
  • In explicit FrameTicks specifications, the tick coordinates are taken to refer to and .
  • With DataReversed->True, tick values decrease from top to bottom.
  • PlotRange->amax specifies that only those between 0 and amax should be shown. »
  • PlotRange->{amin,amax} specifies that between amin and amax should be shown.
  • PlotRange->{{imin,imax},{jmin,jmax}} shows only elements with and in the specified ranges. The top‐left element has , . With the default setting DataReversed->False, increases down the page; increases to the right.
  • PlotRange->{ispec,jspec,aspec} shows only elements in the specified ranges of , , and value. »
  • With the default setting for ColorFunction, PlotRange->{amin,amax} specifies that values from amin to amax should be shown with gray scales varying from white to black.
  • Possible settings for Mesh include:
  • Falsedo not draw any mesh lines
    Truedraw mesh lines between all cells
    Automaticdraw mesh lines around original cells only
    "Nonzero"draw mesh lines around nonzero cells
    {mi,mj}use mesh specifications for the i and j directions
  • With the default setting Frame->Automatic, a frame is drawn only when Mesh->False.
  • For purposes of combining with other graphics, the array element is taken to cover a unit square centered at coordinate position , .
  • 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, is centered at {xmin,ymax}.
  • With the default setting DataRange->All and DataReversed->False, the array element will be taken to cover a unit square centered at coordinate position , .
  • ArrayPlot returns Graphics[Raster[data],opts].
  • ArrayPlot works with SparseArray objects. »
  • List of all options

    • AlignmentPointCenterthe default point in the graphic to align with
      AspectRatioAutomaticratio of height to width
      AxesFalsewhether to draw axes
      AxesLabelNoneaxes labels
      AxesOriginAutomaticwhere axes should cross
      AxesStyle{}style specifications for the axes
      BackgroundNonebackground color for the plot
      BaselinePositionAutomatichow to align with a surrounding text baseline
      BaseStyle{}base style specifications for the graphic
      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
      ContentSelectableAutomaticwhether to allow contents to be selected
      CoordinatesToolOptionsAutomaticdetailed behavior of the coordinates tool
      DataRangeAllthe range of and values to assume
      DataReversedFalsewhether to reverse the order of rows
      Epilog{}primitives rendered after the main plot
      FormatTypeTraditionalFormthe default format type for text
      FrameAutomaticwhether to draw a frame around the plot
      FrameLabelNonelabels for rows and columns
      FrameStyle{}style specifications for the frame
      FrameTicksNonewhat ticks to include on the frame
      FrameTicksStyle{}style specifications for frame ticks
      GridLinesNonegrid lines to draw
      GridLinesStyle{}style specifications for grid lines
      ImageMargins0.the margins to leave around the graphic
      ImagePaddingAllwhat extra padding to allow for labels etc.
      ImageSizeAutomaticthe absolute size at which to render the graphic
      LabelStyle{}style specifications for labels
      MaxPlotPointsInfinitythe maximum number of points to include
      MeshFalsewhether to draw a mesh
      MeshStyleGrayLevel[GoldenRatio-1]the style to use for a mesh
      MethodAutomaticdetails of graphics methods to use
      PlotLabelNonean overall label for the plot
      PlotLegendsNonelegends for datasets
      PlotRangeAllthe range of values to plot
      PlotRangeClippingFalsewhether to clip at the plot range
      PlotRangePaddingAutomatichow much to pad the range of values
      PlotRegionAutomaticthe final display region to be filled
      PlotTheme$PlotThemeoverall theme for the plot
      PreserveImageOptionsAutomaticwhether to preserve image options when displaying new versions of the same graphic
      Prolog{}primitives rendered before the main plot
      RotateLabelTruewhether to rotate y labels on the frame
      TargetUnitsAutomaticunits to display in the plot
      TicksAutomaticaxes ticks
      TicksStyle{}style specifications for axes ticks

Examples

open all close all

Basic Examples  (6)

Plot an array of numbers:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}]

Give explicit color directives to specify colors for individual cells:

Wolfram Language code: ArrayPlot[{{1, 0, 0, Pink}, {1, 1, 0, Pink}, {1, 0, 1, Red}}]

Specify overall color rules:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, ColorRules -> {1 -> Pink, 0 -> Yellow}]

Include a mesh:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Mesh -> True]

Plot a table of data:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}]]

Use a standard blend as a color function:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> "Rainbow"]

Scope  (7)

By default, absolute values go from white to black:

Wolfram Language code: ArrayPlot[{{-1, 0, 1}, {2, 3, 4}}]

Unknown or symbolic values are shown dark red:

Wolfram Language code: ArrayPlot[{{-1, 0, 1}, {2, 3, x}}]

Plot data with units:

Wolfram Language code: ArrayPlot[{{Quantity[0, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[9, "Meters"]}, {Quantity[9, "Meters"], Quantity[7, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"]}, {Quantity[8, "Meters"], Quantity[8, "Meters"], Quantity[9, "Meters"], Quantity[3, "Meters"]}}]

Specify explicit colors for each cell:

Wolfram Language code: ArrayPlot[RandomChoice[{Red, Green, Blue}, {5, 10}]]

Plot a ragged array, padding on the right:

Wolfram Language code: ArrayPlot[{{1}, {1, 1}, {1, 0, 1}, {1, 1, 1, 1}}, Background -> Cyan]

Cells with value None are rendered like the background:

Wolfram Language code: ArrayPlot[Table[If[x == y, None, 1 / (x - y)], {x, -2, 2}, {y, -2, 2}], Background -> Cyan]

Plot a sparse array:

Wolfram Language code: ArrayPlot[SparseArray[{{x_, x_} -> 1, ({x_, y_} /; Abs[x - y] < 3) -> .5}, {10, 10}], Mesh -> True]

Options  (96)

AspectRatio  (2)

Make all cells square:

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> Automatic]

Use a different aspect ratio:

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 1 / 2]

Axes  (4)

By default, ArrayPlot uses a frame instead of axes:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}]]

Use axes instead of a frame:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> True]

Use AxesOrigin to specify where the axes intersect:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> True, AxesOrigin -> {-1, -1}]

Turn each axis on individually:

Wolfram Language code: {ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> {True, False}], ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> {False, True}]}

AxesLabel  (3)

No axes labels are drawn by default:

Wolfram Language code: ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True]

Place a label on the axis:

Wolfram Language code: ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesLabel -> "Y"]

Specify axes labels:

Wolfram Language code: ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesLabel -> {"axis 1", "axes 2"}]

AxesOrigin  (2)

The position of the axes is determined automatically:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True]

Specify an explicit origin for the axes:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesOrigin -> {5, 2}]

AxesStyle  (4)

Change the style for the axes:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red]

Specify the style of each axis:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> {Directive[Thick, Red], Directive[Thick, Blue]}]

Use different styles for the ticks and the axes:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red, TicksStyle -> Blue]

Use different styles for the labels and the axes:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red, LabelStyle -> Blue]

Background  (4)

Background is normally visible only around the edges:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Background -> Blue]

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

Wolfram Language code: ArrayPlot[{{1, 0, 0, None}, {1, 1, 0, None}, {1, None, 1, 0.7}}, Background -> Blue]

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

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Background -> Blue, PlotRange -> {0.2, 1}]

ClippingStyle overrides background color:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Background -> Blue, PlotRange -> {0.2, 1}, ClippingStyle -> Red]

ClippingStyle  (3)

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

Wolfram Language code: ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}]

Show values outside the plot range in red:

Wolfram Language code: ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}, ClippingStyle -> Red]

Show low values in blue and high values in red:

Wolfram Language code: ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}, ClippingStyle -> {Blue, Red}]

ColorFunction  (5)

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

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> Hue]

Use a pure function as the color function:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> (Hue[# ^ 4 / 2]&)]

Use a named color gradient from ColorData:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> "Pastel"]

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

Wolfram Language code: ArrayPlot[Array[GCD, {20, 20}], ColorFunction -> (If[# == 1, Black, White]&), ColorFunctionScaling -> False]

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

Wolfram Language code: ArrayPlot[Array[GCD, {20, 20}], ColorFunction -> Hue, ColorFunctionScaling -> True]

ColorRules  (6)

Specify color rules for explicit values or patterns:

Wolfram Language code: ArrayPlot[Array[GCD, {20, 20}], ColorRules -> {1 -> Red, 2 -> Blue, 3 -> Yellow, _ -> Gray}]

ColorFunction is used if no color rules apply:

Wolfram Language code: ArrayPlot[Array[GCD, {20, 20}], ColorRules -> {1 -> Red}]

The array can contain symbolic values:

Wolfram Language code: ArrayPlot[Transpose[Permutations[{a, b, c}]], ColorRules -> {a -> Red, b -> Yellow, c -> Blue}, Mesh -> True]

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

Wolfram Language code: ArrayPlot[{{1, 0, 1}, {1, 2, 1}, {1, 0, 3}}, ColorRules -> {1 -> Blue, 0 -> Green, _ -> Black}]

Use any patterns in ColorRules:

Wolfram Language code: ArrayPlot[{{-1, 0, 1}, {2, 3, -5}, {1, 2, 1}}, ColorRules -> {_ ? EvenQ -> Red, 1 | -1 -> Blue, x_ /; x < -1 -> Black}]

Rules are used in the order given:

Wolfram Language code: ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue, 1 -> Black}]

DataReversed  (4)

Reverse the order of rows:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], DataReversed -> True]

The frame ticks give the original row numbers:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> True]

Reverse the order of rows and columns:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> {True, True}]

Reverse the order of columns:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> {False, True}]

Epilog  (3)

Use Epilog to superimpose other graphics:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Red, Disk[{4, 4}, 3]}]

The graphics can be translucent:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Opacity[.5], Red, Disk[{4, 4}, 3]}]

Epilog uses the standard Graphics coordinate system:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Red, Disk[{10.5, 10.5}, 1]}]

Frame  (4)

ArrayPlot uses a frame by default:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]

Use FrameFalse to turn off the frame:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> False]

Draw a frame on the left and right edges:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> {{True, True}, {False, False}}]

Draw a frame on the left and bottom edges:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> {{True, False}, {True, False}}]

FrameLabel  (3)

Place a label along the bottom frame of a plot:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameLabel -> {{"Bottom", None}, {None, None}}]

Place labels on each of the edges in the frame:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameLabel -> {{"Bottom", "Top"}, {"Left", "Right"}}]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameLabel -> {{"Bottom", "Top"}, {"Left", "Right"}}, LabelStyle -> Directive[Bold, StandardOrange]]

FrameStyle  (2)

Specify the style of the frame:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameStyle -> Directive[StandardOrange, Thick]]

Specify style for each frame edge:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameStyle -> {{Directive[Green, Thick], Directive[Red]}, {Directive[Orange, Thick], Directive[Blue]}}]

FrameTicks  (13)

Frame ticks are not included by default:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]

Use frame ticks on the bottom edge:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{None, None}, {Automatic, None}}]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> Automatic]

Use FrameTicksAll to include tick labels on all edges:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> All]

Place tick marks at specific positions:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{{10, 20, 30}, {10, 20, 30}}, {{10, 15, 30}, {10, 15, 30}}}]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{{{10, a}, {20, b}, {30, c}}, None}, {{{10, a}, {15, d}, {30, c}}, None}}]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicksStyle -> Red, FrameTicks -> {{{{10, a, .2}, {20, b, .2}, {30, c, .2}}, None}, {{{10, a, .2}, {15, d, Automatic}, {30, c, .2}}, None}}]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicksStyle -> Red, FrameTicks -> {{{{10, a, {.2, .05}}, {20, b, {.2, .2}}, {30, c, {.2, .1}}}, None}, {None, None}}]

Specify a style for each frame tick:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{{{10, a, .5, Directive[Thick, Blue]}, {20, b, .35, Directive[Thick, Green]}, {30, c, .4, Directive[Thick, Yellow, Dashed]}}, Automatic}, {Automatic, Automatic}}]

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

Wolfram Language code: minMeanMax[min_, max_] := {{min, min}, {(max + min) / 2, (max + min) / 2}, {max, max}}
Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{minMeanMax, None}, {minMeanMax, None}}, PlotRangePadding -> None]

Frame ticks without a visible frame:

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], FrameStyle -> Opacity[0], FrameTicksStyle -> Opacity[1], FrameTicks -> All]

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

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], Mesh -> True, Frame -> True, FrameTicks -> All]

Make the frame invisible:

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], Mesh -> True, Frame -> True, FrameStyle -> Opacity[0], FrameTicksStyle -> Opacity[1], FrameTicks -> All]

FrameTicksStyle  (3)

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameStyle -> Directive[Red], FrameTicks -> Automatic]

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

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicksStyle -> Directive[Red, Thick], FrameTicks -> Automatic]

Use a different style for the different frame edges:

Wolfram Language code: ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> True, FrameTicksStyle -> {{Directive[Magenta, Thick], Blue}, {Red, Darker@Green}}, FrameTicks -> Automatic]

GridLines  (3)

Draw grids across the plot:

Wolfram Language code: ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> Automatic]

Draw grid lines at specified positions:

Wolfram Language code: ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> {{1, 2.5, 4}, {1, 2.5, 4}}]

Specify grid styles:

Wolfram Language code: ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> Automatic, GridLinesStyle -> Directive[Orange, Dashed]]

ImageSize  (7)

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

Wolfram Language code: {ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Tiny], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Small]}

Specify the width of the plot:

Wolfram Language code: {ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> 150], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 1.5, ImageSize -> 150]}

Specify the height of the plot:

Wolfram Language code: {ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> {Automatic, 200}], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 2, ImageSize -> {Automatic, 200}]}

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

Wolfram Language code: {ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> UpTo[200]], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 2, ImageSize -> UpTo[200]]}

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

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> {200, 200}]

Setting AspectRatioFull will fill the available space:

Wolfram Language code: ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> Full, ImageSize -> {200, 200}]

Use maximum sizes for the width and height:

Wolfram Language code: {ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> {UpTo[100], UpTo[150]}], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 2, ImageSize -> {UpTo[100], UpTo[200]}]}

Use ImageSizeFull to fill the available space in an object:

Wolfram Language code: Framed[Pane[ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Full], {150, 150}]]

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

Wolfram Language code: Framed[Pane[ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> Full, ImageSize -> {Scaled[0.5], Scaled[0.5]}], {200, 100}]]

MaxPlotPoints  (1)

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

Wolfram Language code: ArrayPlot[CellularAutomaton[60, {{1}, 0}, 200]]
Wolfram Language code: ArrayPlot[CellularAutomaton[60, {{1}, 0}, 200], MaxPlotPoints -> 50]

Mesh  (7)

Insert mesh lines between all cells:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> All]

Insert 15 row mesh lines and 5 column mesh lines:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {15, 5}]

Insert mesh lines around the first 10 columns:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {None, Range[0, 10]}]

Use a sequence of colors for the mesh lines:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {None, Table[{i, Hue[i / 10]}, {i, 0, 10}]}]

Insert mesh lines after the first and second rows:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {{1, 2}, None}]

Use MeshAutomatic to draw mesh for the data in a ragged array:

Wolfram Language code: ArrayPlot[Table[If[i < j, 0, 1], {j, 20}, {i, 2j}], Mesh -> Automatic]

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

Wolfram Language code: ArrayPlot[Table[If[i < j, 0, 1], {j, 20}, {i, 2j}], Mesh -> "Nonzero"]

MeshStyle  (2)

Default mesh style:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], Mesh -> All]

Make the mesh pink:

Wolfram Language code: ArrayPlot[RandomReal[1, {10, 20}], Mesh -> All, MeshStyle -> Pink]

PlotLegends  (5)

No legend is used by default:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}]

Generate a legend automatically:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 1}, {1, 1, 0, 1}, {1, 0, 1, 0}}, PlotLegends -> Automatic, ImageSize -> 100]
Wolfram Language code: ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, PlotLegends -> Automatic, ImageSize -> 100]

PlotLegends automatically picks up ColorFunction:

Wolfram Language code: Table[ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> cf, PlotLegends -> Placed[Automatic, Below], ImageSize -> 100], {cf, {"Pastel", GrayLevel}}]

Legend uses ColorRules as labels:

Wolfram Language code: ArrayPlot[Transpose[Permutations[{a, b, c}]], ColorRules -> {a -> Red, b -> Yellow, c -> Blue}, Mesh -> True, PlotLegends -> Automatic]

Use Placed to place legend outside the plot:

Wolfram Language code: Table[ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue}, PlotLegends -> Placed[Automatic, pl]], {pl, {After, Before}}]
Wolfram Language code: Table[ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue}, PlotLegends -> Placed[Automatic, pl]], {pl, {Above, Below}}]

PlotRange  (5)

Plot all elements:

Wolfram Language code: ArrayPlot[Array[GCD, {10, 10}]]

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

Wolfram Language code: ArrayPlot[Array[GCD, {10, 10}], PlotRange -> 3]

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

Wolfram Language code: ArrayPlot[Array[GCD, {10, 10}], PlotRange -> {{2, 6}, All, 3}]

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

Wolfram Language code: {ArrayPlot[{{0, 1}, {1, 2}}, PlotRange -> {-2, 2}], ArrayPlot[{{0, 1}, {1, 2}}, PlotRange -> {0, 2}]}

Plot positive elements only:

Wolfram Language code: ArrayPlot[RandomReal[{-10, 10}, {10, 20}], PlotRange -> {0, All}]

PlotTheme  (1)

Use a theme with detailed ticks and a legend:

Wolfram Language code: ArrayPlot[RandomReal[{-10, 10}, {20, 20}], PlotTheme -> "Detailed"]

Move the legend below the plot:

Wolfram Language code: ArrayPlot[RandomReal[{-10, 10}, {20, 20}], PlotTheme -> "Detailed", PlotLegends -> Placed[Automatic, Below]]

Applications  (11)

Plot a two-color cellular automaton evolution:

Wolfram Language code: ArrayPlot[CellularAutomaton[30, {{1}, 0}, 50]]

Plot a three-color cellular automaton evolution:

Wolfram Language code: ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 80]]

Use colors rather than gray levels:

Wolfram Language code: ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 80], ColorRules -> {0 -> Black, 1 -> Red, 2 -> Yellow}]

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

Wolfram Language code: ArrayPlot[Im[ Inverse[FourierMatrix[25, WorkingPrecision -> MachinePrecision]]], ColorFunction -> "TemperatureMap"]

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

Wolfram Language code: ArrayPlot[Inverse[Table[(1 + Mod[i j, 19]) / (i + j), {i, 20}, {j, 20}]], ColorFunction -> "DeepSeaColors"]

Show positive entries as gray and others as yellow:

Wolfram Language code: ArrayPlot[Inverse[Table[(1 + Mod[i j, 19]) / (i + j), {i, 20}, {j, 20}]], ColorFunction -> (If[# > 0, Yellow, Gray]&), ColorFunctionScaling -> False]

Create a list of array plots:

Wolfram Language code: Table[ArrayPlot[Table[Mod[Binomial[i, j], n], {i, 30}, {j, 30}]], {n, 2, 5}]

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

Wolfram Language code: ArrayPlot[Table[Evaluate[Sum[Sin[RandomReal[10, 2].{x, y}], {5}]], {x, 0, 5, .1}, {y, 0, 5, .1}]]

Plot image-processed data:

Wolfram Language code: ArrayPlot[ListConvolve[{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, CellularAutomaton[30, {{1}, 0}, 50]]]

Plot a color map:

Wolfram Language code: ArrayPlot[{Range[0, 1, .01]}, AspectRatio -> 1 / 4, ColorFunction -> Hue]

Use a special color for non-numeric data:

Wolfram Language code: ArrayPlot[Table[1 / (x ^ 2 + y ^ 2), {x, -5, 5}, {y, -5, 5}], ColorRules -> {ComplexInfinity -> Red}]

Digits of powers of 3 in base 2:

Wolfram Language code: ArrayPlot[PadLeft[Table[IntegerDigits[3 ^ n, 2], {n, 70}]]]

Plot a sparse matrix in black and white:

Wolfram Language code: data = Import[FileNameJoin[{"LinearAlgebraExamples", "Data", "west0381.mtx"}]];
Wolfram Language code: ArrayPlot[data, ColorFunction -> "Monochrome"]

Properties & Relations  (8)

An empty array yields a blank picture:

Wolfram Language code: ArrayPlot[{{}}]

Grid arranges elements the same way as ArrayPlot:

Wolfram Language code: ArrayPlot[{{1, 0, 0, 0}, {1, 0.5, 1, 1}, {1, 0, 0.3, 1}}]
Wolfram Language code: Grid[{{1, 0, 0, 0}, {1, 0.5, 1, 1}, {1, 0, 0.3, 1}}]

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

Wolfram Language code: {ArrayPlot[{{0, 1}, {2, 3}}], Graphics[Raster[{{0, 1}, {2, 3}} / 3]]}

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

Wolfram Language code: Graphics[Raster[Reverse[1 - {{0, 1}, {2, 3}} / 3]]]

Use ArrayPlot3D for 3D arrays of data:

Wolfram Language code: ArrayPlot3D[RandomInteger[5, {3, 4, 5}]]

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

Wolfram Language code: MatrixPlot[Fourier[Table[UnitStep[i, 4 - i] UnitStep[j, 7 - j], {i, -50, 50}, {j, -50, 50}]]]

Or for large sparse matrices:

Wolfram Language code: ExampleData[{"Matrix", "WEST2021"}, "Matrix"]
Wolfram Language code: MatrixPlot[%]

Use ReliefPlot for medical and geographic data:

Wolfram Language code: ReliefPlot[Import["http://exampledata.wolfram.com/hailey.dem.gz", "Data"], ColorFunction -> "GreenBrownTerrain", MaxPlotPoints -> 200]

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

Wolfram Language code: ListDensityPlot[Table[x + Sin[3x + y ^ 2], {x, -3, 3, 0.1}, {y, -3, 3, 0.1}], ColorFunction -> "SunsetColors"]
Wolfram Language code: ArrayPlot[Reverse[Table[x + Sin[3x + y ^ 2], {x, -3, 3, 0.05}, {y, -3, 3, 0.05}]], ColorFunction -> "SunsetColors"]

Use GraphPlot for visualizing adjacency matrices:

Wolfram Language code: GraphPlot[RandomChoice[{0.01, 0.99} -> {1, 0}, {100, 100}]]

Possible Issues  (2)

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

Wolfram Language code: data = HankelMatrix[Table[(-1) ^ i / i, {i, 25}]];
Wolfram Language code: ArrayPlot[data]

Use MatrixPlot instead (or provide a custom ColorFunction):

Wolfram Language code: MatrixPlot[data, FrameTicks -> None]

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

Wolfram Language code: ArrayPlot[{{10000, 1, -1, 0}}]

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

Wolfram Language code: MatrixPlot[{{10000, 1, -1, 0}}]

Neat Examples  (2)

Plot the Sin function at integer points:

Wolfram Language code: ArrayPlot[Table[Sin[x y], {x, -40, 40}, {y, -40, 40}]]

Interactively map GCD values onto colors using Hue:

Wolfram Language code: Manipulate[ArrayPlot[Array[GCD, {50, 50}], ColorFunction -> (Hue[Mod[# + a, 1]]&), ColorFunctionScaling -> True], {a, 0, 1}]

See Also

MatrixPlot  ReliefPlot  ListDensityPlot  ArrayPlot3D  DensityPlot  Raster  ListPlot3D  Grid  GraphicsGrid  SparseArray  CellularAutomaton  PadLeft  ArrayFlatten  GraphPlot  ClickPane

Function Repository: DottedArrayPlot  ByteArrayPlot  TessellationPlot

Related Guides

    ▪
  • Data Visualization
  • ▪
  • GPU Computing
  • ▪
  • Computational Systems
  • ▪
  • GPU Computing with NVIDIA
  • ▪
  • GPU Computing with Apple
  • ▪
  • Handling Arrays of Data
  • ▪
  • Charting and Information Visualization
  • ▪
  • Scientific Data Analysis
  • ▪
  • Function Visualization
  • ▪
  • Numerical Data

Related Links

  • An Elementary Introduction to the Wolfram Language : Arrays, or Lists of Lists

History

Introduced in 2004 (5.1) | Updated in 2007 (6.0) ▪ 2012 (9.0) ▪ 2014 (10.0) ▪ 2020 (12.1) ▪ 2021 (12.3) ▪ 2025 (14.3)

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

Text

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

CMS

Wolfram Language. 2004. "ArrayPlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. 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_2026_arrayplot, author="Wolfram Research", title="{ArrayPlot}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayPlot.html}", note=[Accessed: 12-November-2026]}

BibLaTeX

@online{reference.wolfram_2026_arrayplot, organization={Wolfram Research}, title={ArrayPlot}, year={2025}, url={https://reference.wolfram.com/language/ref/ArrayPlot.html}, note=[Accessed: 12-November-2026]}

Top
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.