ArrayPlot[array]
生成一个图形,图形中数组的值以离散的方形阵列表示.
ArrayPlot
ArrayPlot[array]
生成一个图形,图形中数组的值以离散的方形阵列表示.
更多信息和选项
- 在默认情况下,ArrayPlot[array] 每页从上至下顺序设置连续的 array 行,从左至右设置连续的列,类似一个表或网格的通常格式. »
- 如果 array 含有 0 和 1,则 1 显示为黑色正方形,0 显示为白色正方形.
- ArrayPlot 缺省下以灰色输出,其中 0 值显示为白色,最大正或负值显示为黑色. »
- 当对 PlotRange 给出一个明确设置时,ArrayPlot 缺省下最小值为白色,最大值为黑色.
- array 中的值可以是与它们关联的带有单位的量值.
- 可以使用下列特殊表值: »
-
None 背景色 颜色指令 指定具体颜色 - 如果 array 不规则,利用背景对较短行的右侧进行填补. »
- ArrayPlot 具有和 Graphics 相同的选项,并包含以下附加选项及变化: [所有选项的列表]
-
AspectRatio Automatic 高宽比 ClippingStyle None 如何显示其值被剪切的单元 ColorFunction Automatic 每个单元的着色方式 ColorFunctionScaling True 是否为 ColorFunction 设定参数 ColorRules Automatic 根据数值确定颜色的规则 DataRange All 采用的
和
值范围DataReversed False 是否采用行的逆顺序 Frame Automatic 是否在图形的周围绘制框架 FrameLabel None 行和列的标签 FrameTicks None 框架上刻度类型 MaxPlotPoints Infinity 包含的最大点数 Mesh False 是否绘制网格线 MeshStyle GrayLevel[GoldenRatio-1] 网格线采用的样式 PlotLegends None 数据集图例 PlotRange All 绘图值的范围 PlotTheme $PlotTheme 图形的总主题 TargetUnits Automatic 图形中所显示的单位 - ColorRules 可接受以下设置:
-
Automatic 使用默认的颜色 "Colors" 对不同的值使用不同的颜色 "Monochrome" 使用灰度颜色 {valcolor,…} 用 color 作为 val 的样式 - ColorRules 给出的规则应用于每个单元的
值. 这些规则可以包含模式. » - 如果未采用 ColorRules 中的任何规则,则 ColorFunction 被用于指定的颜色.
- 缺省设置 ColorRules->Automatic 时,ColorFunction->f 采用一个明确的设置而非 ColorRules.
- 当 ColorFunctionScaling->False 时,每个
值作为参数提供给由 ColorFunction 给出的任意函数. » - 对于 ColorFunctionScaling->True,给定的值位于 0 和 1 之间. »
- 如果指定单元的颜色为 None, 则该单元采用背景色进行着色.
- 如果未指定单元任何颜色,则该单元以缺省的深红色进行着色.
- 对于 DataReversed->True,其行的顺序是逆顺序,所以每行从下往上进行,最后一行在顶部.
- 设置 FrameTicks->Automatic 时,刻度标于整数位置,通常是 5 或 10 的倍数.
- 设置 FrameTicks->All 时,刻度标于最小和最大的
和
处. - 在指定的 FrameTicks 中,采用刻度坐标与
和
相参照. - 对于 DataReversed->True,刻度值从顶到底递减.
- PlotRange->amax 指定只应显示 0 和 amax 之间的
. » - PlotRange->{amin,amax} 指定只显示 amin 和 amax 之间的
. - PlotRange->{{imin,imax},{jmin,jmax}} 只显示指定相关
和
范围内的元素. 左上方元素为
,
. 对于缺省设置 DataReversed->False,
在该页向下递增;
向右递增. - PlotRange->{ispec,jspec,aspec} 只显示
、
指定范围内的元素和值. » - 对于 ColorFunction 的缺省设置,PlotRange->{amin,amax} 指定从 amin 到 amax 的值应该以从白色到黑色变化的灰色显示.
- Mesh 的可能的设置包括:
-
False 不要绘制任何网格线 True 在所有单元间绘制网格线 Automatic 只在原始单元周围绘制网格线 "Nonzero" 在非零单元周围绘制网格线 {mi,mj} 在 i 和 j 方向上应用网格规范 - 缺省设置 Frame->Automatic,只有当 Mesh->False 时绘制框架.
- 为了与其它各图形组合,数组元素
覆盖于以坐标
和
为中心的单位方形. - 设置 DataRange->{{xmin,xmax},{ymin,ymax}},指定在水平方向,连续单元的中心应该等间距位于 xmin 和 xmax 之间,垂直方向位于 ymin 和 ymax 之间. 对于缺省设置 DataReversed->False,
以 {xmin,ymax} 为中心. - 缺省设置 DataRange->All 和 DataReversed->False,数组元素
将覆盖一个以坐标位置
,
为中心的单位方形. - ArrayPlot 返回 Graphics[Raster[data],opts].
- ArrayPlot 对 SparseArray对象起作用. »
所有选项的列表
范例
打开所有单元 关闭所有单元基本范例 (6)
ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}]ArrayPlot[{{1, 0, 0, Pink}, {1, 1, 0, Pink}, {1, 0, 1, Red}}]ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, ColorRules -> {1 -> Pink, 0 -> Yellow}]ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Mesh -> True]ArrayPlot[RandomReal[1, {10, 20}]]ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> "Rainbow"]范围 (7)
ArrayPlot[{{-1, 0, 1}, {2, 3, 4}}]ArrayPlot[{{-1, 0, 1}, {2, 3, x}}]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"]}}]ArrayPlot[RandomChoice[{Red, Green, Blue}, {5, 10}]]ArrayPlot[{{1}, {1, 1}, {1, 0, 1}, {1, 1, 1, 1}}, Background -> Cyan]设置 None 值的单元着色方式同背景一样:
ArrayPlot[Table[If[x == y, None, 1 / (x - y)], {x, -2, 2}, {y, -2, 2}], Background -> Cyan]ArrayPlot[SparseArray[{{x_, x_} -> 1, ({x_, y_} /; Abs[x - y] < 3) -> .5}, {10, 10}], Mesh -> True]选项 (96)
AspectRatio (2)
Axes (4)
默认情况下,ArrayPlot 使用边框而非轴:
ArrayPlot[RandomReal[1, {10, 20}]]ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> True]使用 AxesOrigin 指定轴的相交处:
ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> True, AxesOrigin -> {-1, -1}]{ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> {True, False}], ArrayPlot[RandomReal[1, {10, 20}], Frame -> False, Axes -> {False, True}]}AxesLabel (3)
ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True]ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesLabel -> "Y"]ArrayPlot[CellularAutomaton[20, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesLabel -> {"axis 1", "axes 2"}]AxesOrigin (2)
AxesStyle (4)
ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> {Directive[Thick, Red], Directive[Thick, Blue]}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red, TicksStyle -> Blue]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Frame -> False, Axes -> True, AxesStyle -> Red, LabelStyle -> Blue]Background (4)
Background 通常只在边缘周围可见:
ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Background -> Blue]当明确指定 None 时,背景都会“透出”:
ArrayPlot[{{1, 0, 0, None}, {1, 1, 0, None}, {1, None, 1, 0.7}}, Background -> Blue]对于绘制范围外的值而言,Background 在默认情况下也会透出:
ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, Background -> Blue, PlotRange -> {0.2, 1}]ClippingStyle 覆盖了背景颜色:
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)
ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}]ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}, ClippingStyle -> Red]ArrayPlot[Table[x + y, {x, -10, 10}, {y, -10, 10}], PlotRange -> {-10, 10}, ClippingStyle -> {Blue, Red}]ColorFunction (5)
根据 Hue,把从 0 至 1 的值映射到颜色上:
ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> Hue]ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> (Hue[# ^ 4 / 2]&)]用 ColorData 中一个已命名的颜色梯度:
ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> "Pastel"]ArrayPlot[Array[GCD, {20, 20}], ColorFunction -> (If[# == 1, Black, White]&), ColorFunctionScaling -> False]对于 ColorFunctionScaling->True,其值首先被调整在 0 和 1 之间:
ArrayPlot[Array[GCD, {20, 20}], ColorFunction -> Hue, ColorFunctionScaling -> True]ColorRules (6)
ArrayPlot[Array[GCD, {20, 20}], ColorRules -> {1 -> Red, 2 -> Blue, 3 -> Yellow, _ -> Gray}]ColorFunction 用于没有使用任何颜色规则的条件下:
ArrayPlot[Array[GCD, {20, 20}], ColorRules -> {1 -> Red}]ArrayPlot[Transpose[Permutations[{a, b, c}]], ColorRules -> {a -> Red, b -> Yellow, c -> Blue}, Mesh -> True]ArrayPlot[{{1, 0, 1}, {1, 2, 1}, {1, 0, 3}}, ColorRules -> {1 -> Blue, 0 -> Green, _ -> Black}]在 ColorRules 中使用任意模式:
ArrayPlot[{{-1, 0, 1}, {2, 3, -5}, {1, 2, 1}}, ColorRules -> {_ ? EvenQ -> Red, 1 | -1 -> Blue, x_ /; x < -1 -> Black}]ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue, 1 -> Black}]DataReversed (4)
ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], DataReversed -> True]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> True]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> {True, True}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], FrameTicks -> Automatic, DataReversed -> {False, True}]Epilog (3)
用 Epilog 叠加其它图形:
ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Red, Disk[{4, 4}, 3]}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Opacity[.5], Red, Disk[{4, 4}, 3]}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Epilog -> {Red, Disk[{10.5, 10.5}, 1]}]Frame (4)
ArrayPlot 默认情况下使用边框:
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> False]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> {{True, True}, {False, False}}]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], Frame -> {{True, False}, {True, False}}]FrameLabel (3)
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameLabel -> {{"Bottom", None}, {None, None}}]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameLabel -> {{"Bottom", "Top"}, {"Left", "Right"}}]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)
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameStyle -> Directive[StandardOrange, Thick]]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)
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{None, None}, {Automatic, None}}]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]]]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> Automatic]设置 FrameTicksAll 可在每边边框上放置刻度标签:
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> All]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}}}]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}}]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}}]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}}]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}}]minMeanMax[min_, max_] := {{min, min}, {(max + min) / 2, (max + min) / 2}, {max, max}}ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicks -> {{minMeanMax, None}, {minMeanMax, None}}, PlotRangePadding -> None]ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], FrameStyle -> Opacity[0], FrameTicksStyle -> Opacity[1], FrameTicks -> All]添加网格的情况下,必须设置 Frame->True 才可以绘制边框刻度:
ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], Mesh -> True, Frame -> True, FrameTicks -> All]ArrayPlot[Mod[Array[Binomial, {8, 8}, 0], 2], Mesh -> True, Frame -> True, FrameStyle -> Opacity[0], FrameTicksStyle -> Opacity[1], FrameTicks -> All]FrameTicksStyle (3)
默认情况下,边框刻度线和边框刻度线标签使用与边框相同的样式:
ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameStyle -> Directive[Red], FrameTicks -> Automatic]ArrayPlot[Im[Table[Exp[2. Pi I i j / 32], {i, 0, 32}, {j, 0, 32}]], FrameTicksStyle -> Directive[Red, Thick], FrameTicks -> Automatic]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)
ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> Automatic]ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> {{1, 2.5, 4}, {1, 2.5, 4}}]ArrayPlot[RandomInteger[1, {5, 5}], GridLines -> Automatic, GridLinesStyle -> Directive[Orange, Dashed]]ImageSize (7)
使用有命名的尺寸如 Tiny、Small、Medium 和 Large:
{ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Tiny], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Small]}{ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> 150], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 1.5, ImageSize -> 150]}{ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> {Automatic, 200}], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 2, ImageSize -> {Automatic, 200}]}{ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> UpTo[200]], ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> 2, ImageSize -> UpTo[200]]}ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> {200, 200}]设置 AspectRatioFull 将填充可用区域:
ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> Full, ImageSize -> {200, 200}]{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]}]}Framed[Pane[ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], ImageSize -> Full], {150, 150}]]Framed[Pane[ArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 2], AspectRatio -> Full, ImageSize -> {Scaled[0.5], Scaled[0.5]}], {200, 100}]]MaxPlotPoints (1)
用 MaxPlotPoints 直接限制在每个方向上绘制的元素数量:
ArrayPlot[CellularAutomaton[60, {{1}, 0}, 200]]ArrayPlot[CellularAutomaton[60, {{1}, 0}, 200], MaxPlotPoints -> 50]Mesh (7)
ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> All]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {15, 5}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {None, Range[0, 10]}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {None, Table[{i, Hue[i / 10]}, {i, 0, 10}]}]ArrayPlot[CellularAutomaton[30, {{1}, 0}, 10], Mesh -> {{1, 2}, None}]用 MeshAutomatic 为不规整数组中的数据绘制网格线:
ArrayPlot[Table[If[i < j, 0, 1], {j, 20}, {i, 2j}], Mesh -> Automatic]用 Mesh"Nonzero" 在非零单元周围绘制网格线:
ArrayPlot[Table[If[i < j, 0, 1], {j, 20}, {i, 2j}], Mesh -> "Nonzero"]MeshStyle (2)
PlotLegends (5)
ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}]ArrayPlot[{{1, 0, 0, 1}, {1, 1, 0, 1}, {1, 0, 1, 0}}, PlotLegends -> Automatic, ImageSize -> 100]ArrayPlot[{{1, 0, 0, 0.3}, {1, 1, 0, 0.3}, {1, 0, 1, 0.7}}, PlotLegends -> Automatic, ImageSize -> 100]PlotLegends 自动挑选 ColorFunction:
Table[ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> cf, PlotLegends -> Placed[Automatic, Below], ImageSize -> 100], {cf, {"Pastel", GrayLevel}}]图例使用 ColorRules 作为标签:
ArrayPlot[Transpose[Permutations[{a, b, c}]], ColorRules -> {a -> Red, b -> Yellow, c -> Blue}, Mesh -> True, PlotLegends -> Automatic]使用 Placed 在图形外部放置图例:
Table[ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue}, PlotLegends -> Placed[Automatic, pl]], {pl, {After, Before}}]Table[ArrayPlot[{{1, 0, 1}, {1, 1, 0}}, ColorRules -> {1 -> Red, 0 -> Blue}, PlotLegends -> Placed[Automatic, pl]], {pl, {Above, Below}}]PlotRange (5)
ArrayPlot[Array[GCD, {10, 10}]]ArrayPlot[Array[GCD, {10, 10}], PlotRange -> 3]PlotRange 的前两个值中,指定了包含的行和列的范围:
ArrayPlot[Array[GCD, {10, 10}], PlotRange -> {{2, 6}, All, 3}]在指定绘制范围情况下,{amin,amax} 的颜色范围从 amin 处的白色一直到 amax 处的黑色:
{ArrayPlot[{{0, 1}, {1, 2}}, PlotRange -> {-2, 2}], ArrayPlot[{{0, 1}, {1, 2}}, PlotRange -> {0, 2}]}ArrayPlot[RandomReal[{-10, 10}, {10, 20}], PlotRange -> {0, All}]应用 (11)
ArrayPlot[CellularAutomaton[30, {{1}, 0}, 50]]ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 80]]ArrayPlot[CellularAutomaton[{1635, {3, 1}}, {{1}, 0}, 80], ColorRules -> {0 -> Black, 1 -> Red, 2 -> Yellow}]ArrayPlot[Im[
Inverse[FourierMatrix[25, WorkingPrecision -> MachinePrecision]]], ColorFunction -> "TemperatureMap"]ArrayPlot[Inverse[Table[(1 + Mod[i j, 19]) / (i + j), {i, 20}, {j, 20}]], ColorFunction -> "DeepSeaColors"]ArrayPlot[Inverse[Table[(1 + Mod[i j, 19]) / (i + j), {i, 20}, {j, 20}]], ColorFunction -> (If[# > 0, Yellow, Gray]&), ColorFunctionScaling -> False]Table[ArrayPlot[Table[Mod[Binomial[i, j], n], {i, 30}, {j, 30}]], {n, 2, 5}]ArrayPlot[Table[Evaluate[Sum[Sin[RandomReal[10, 2].{x, y}], {5}]], {x, 0, 5, .1}, {y, 0, 5, .1}]]ArrayPlot[ListConvolve[{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, CellularAutomaton[30, {{1}, 0}, 50]]]ArrayPlot[{Range[0, 1, .01]}, AspectRatio -> 1 / 4, ColorFunction -> Hue]ArrayPlot[Table[1 / (x ^ 2 + y ^ 2), {x, -5, 5}, {y, -5, 5}], ColorRules -> {ComplexInfinity -> Red}]ArrayPlot[PadLeft[Table[IntegerDigits[3 ^ n, 2], {n, 70}]]]data = Import[FileNameJoin[{"LinearAlgebraExamples", "Data", "west0381.mtx"}]];ArrayPlot[data, ColorFunction -> "Monochrome"]属性和关系 (8)
ArrayPlot[{{}}]ArrayPlot[{{1, 0, 0, 0}, {1, 0.5, 1, 1}, {1, 0, 0.3, 1}}]Grid[{{1, 0, 0, 0}, {1, 0.5, 1, 1}, {1, 0, 0.3, 1}}]对于 ArrayPlot ,Raster 逆转排列元素,并且颜色相反:
{ArrayPlot[{{0, 1}, {2, 3}}], Graphics[Raster[{{0, 1}, {2, 3}} / 3]]}使数组显示的方式和 ArrayPlot 相同:
Graphics[Raster[Reverse[1 - {{0, 1}, {2, 3}} / 3]]]用 ArrayPlot3D 绘制 3D 数组:
ArrayPlot3D[RandomInteger[5, {3, 4, 5}]]当值有大的范围和许多不同值时,使用 MatrixPlot:
MatrixPlot[Fourier[Table[UnitStep[i, 4 - i] UnitStep[j, 7 - j], {i, -50, 50}, {j, -50, 50}]]]ExampleData[{"Matrix", "WEST2021"}, "Matrix"]MatrixPlot[%]ReliefPlot 用于医学和地理数据:
ReliefPlot[Import["http://exampledata.wolfram.com/hailey.dem.gz", "Data"], ColorFunction -> "GreenBrownTerrain", MaxPlotPoints -> 200]ListDensityPlot 用于从连续密度取样的结构或非结构数据:
ListDensityPlot[Table[x + Sin[3x + y ^ 2], {x, -3, 3, 0.1}, {y, -3, 3, 0.1}], ColorFunction -> "SunsetColors"]ArrayPlot[Reverse[Table[x + Sin[3x + y ^ 2], {x, -3, 3, 0.05}, {y, -3, 3, 0.05}]], ColorFunction -> "SunsetColors"]GraphPlot 用于图形显示相邻矩阵:
GraphPlot[RandomChoice[{0.01, 0.99} -> {1, 0}, {100, 100}]]可能存在的问题 (2)
ArrayPlot 可能无法区分数量较多的不同值:
data = HankelMatrix[Table[(-1) ^ i / i, {i, 25}]];ArrayPlot[data]用 MatrixPlot 替代. (或者提供一种自定义的 ColorFunction):
MatrixPlot[data, FrameTicks -> None]ArrayPlot[{{10000, 1, -1, 0}}]MatrixPlot 对各项进行尺度缩放,以使绝对值相对较小的值可以显示出来:
MatrixPlot[{{10000, 1, -1, 0}}]相关指南
-
▪
- 数据可视化 ▪
- GPU 计算 ▪
- 计算系统 ▪
- NVIDIA GPU 计算 ▪
- Apple GPU 计算 ▪
- 大型数组的处理 ▪
- 图表和信息可视化 ▪
- 科学数据分析 ▪
- 函数可视化 ▪
- 数值数据
历史
2004年引入 (5.1) | 在以下年份被更新:2007 (6.0) ▪ 2012 (9.0) ▪ 2014 (10.0) ▪ 2020 (12.1) ▪ 2021 (12.3) ▪ 2025 (14.3)
文本
Wolfram Research (2004),ArrayPlot,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ArrayPlot.html (更新于 2025 年).
CMS
Wolfram 语言. 2004. "ArrayPlot." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/ArrayPlot.html.
APA
Wolfram 语言. (2004). ArrayPlot. Wolfram 语言与系统参考资料中心. 追溯自 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: 15-July-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: 15-July-2026]}