---
title: "ComplexArrayPlot"
language: "en"
type: "Symbol"
summary: "ComplexArrayPlot[array] generates a plot in which complex values zij in an array array are shown in a discrete array of squares with Arg[zij] indicated by color and Abs[zij] by shading."
keywords: 
- complex matrix structure plot
- complex cellular automaton
- complex discrete data plot
- ragged array plot
- colormap plot
- elements plot
- complex argument plot
canonical_url: "https://reference.wolfram.com/language/ref/ComplexArrayPlot.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Complex Visualization"
    link: "https://reference.wolfram.com/language/guide/ComplexVisualization.en.md"
related_functions: 
  - 
    title: "ArrayPlot"
    link: "https://reference.wolfram.com/language/ref/ArrayPlot.en.md"
  - 
    title: "ComplexPlot"
    link: "https://reference.wolfram.com/language/ref/ComplexPlot.en.md"
  - 
    title: "ComplexPlot3D"
    link: "https://reference.wolfram.com/language/ref/ComplexPlot3D.en.md"
  - 
    title: "ComplexListPlot"
    link: "https://reference.wolfram.com/language/ref/ComplexListPlot.en.md"
  - 
    title: "MatrixPlot"
    link: "https://reference.wolfram.com/language/ref/MatrixPlot.en.md"
  - 
    title: "ReliefPlot"
    link: "https://reference.wolfram.com/language/ref/ReliefPlot.en.md"
  - 
    title: "ListDensityPlot"
    link: "https://reference.wolfram.com/language/ref/ListDensityPlot.en.md"
  - 
    title: "Grid"
    link: "https://reference.wolfram.com/language/ref/Grid.en.md"
  - 
    title: "GraphicsGrid"
    link: "https://reference.wolfram.com/language/ref/GraphicsGrid.en.md"
  - 
    title: "SparseArray"
    link: "https://reference.wolfram.com/language/ref/SparseArray.en.md"
---
# ComplexArrayPlot

ComplexArrayPlot[array] generates a plot in which complex values zij in an array array are shown in a discrete array of squares with Arg[zij] indicated by color and Abs[zij] by shading.

## Details and Options

* ``ComplexArrayPlot`` is used to visualize tables of complex numbers.

* ``ComplexArrayPlot[array]`` by default arranges successive rows of the ``m\[Cross]n`` dimensional ``array`` down the page and successive columns across, just as a table or grid would normally be formatted.

[image]

* ``ComplexArrayPlot`` uses a cyclic color function over the values of ``Arg[zij]`` and shading to indicate values of ``Abs[zij]``. Complex numbers with large moduli are lighter than numbers with smaller moduli.

* In ``ComplexArrayPlot[array]``, ``array`` can have the following forms:

|                                             |                          |
| ------------------------------------------- | ------------------------ |
| {{z11, z12, …, z1n}, …, {zm1, zm2, …, zmn}} | values zij               |
| SparseArray                                 | values as a normal array |
| NumericArray                                | values as a normal array |
| Dataset                                     | values as a normal array |

* The following special entries can be used for the ``zij`` :

|                 |                  |
| --------------- | ---------------- |
| None            | background color |
| color directive | specified color  |

* If ``array`` is ragged, shorter rows are treated as padded on the right with background.

* ``ComplexArrayPlot`` has the same options as ``Graphics``, with the following additions and changes:  []

|     |     |     |
| :-------------------- | :------------------------- | :----------------------------------------------------------------------------------------------------- |
| AspectRatio  | Automatic | ratio of height to width  |
| ClippingStyle  | None | how to show cells whose values are clipped |
| ColorFunction  | Automatic | how each cell should be colored  |
| ColorFunctionScaling  | True | whether to scale the argument to ColorFunction |
| ColorRules  | Automatic | rules for determining colors from values  |
| DataRange  | All | the range of $x$ and $y$ values to assume  |
| DataReversed  | False | whether to reverse the order of rows |
| Frame | Automatic | whether to draw a frame around the plot  |
| FrameLabel | None | labels for rows and columns |
| FrameTicks | None | what ticks to include on the frame  |
| MaxPlotPoints  | Infinity | the maximum number of points to include  |
| Mesh  | False | whether to draw a mesh  |
| MeshStyle  | GrayLevel[GoldenRatio - 1] | the style to use for a mesh  |
| PerformanceGoal | \$PerformanceGoal | aspects of performance to try to optimize |
| PlotLegends  | None | legends for datasets |
| PlotRange  | All | the range of values to plot  |
| PlotTheme  | \$PlotTheme | overall theme for the plot |
| TargetUnits | Automatic | units to display in the plot |

* The rules given by ``ColorRules`` are applied to the value $z_{ij}$ 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 -> cfunc`` is used instead of ``ColorRules``.

* ``ColorFunction -> {cfunc, sfunc}`` uses ``cfunc`` to generate the base color and ``sfunc`` to adjust the color to highlight features.

* Possible named settings for ``sfunc`` are:

|         |                       |                                                                |
| ------- | --------------------- | -------------------------------------------------------------- |
| [image] | Automatic             | automatic shading based on Abs[z]                              |
| [image] | "MaxAbs"              | light shading of large values of Abs[z]                        |
| [image] | "LocalMaxAbs"         | light shading of an upper quantile of Abs[z]                   |
| [image] | "GlobalAbs"           | dark to light shading of small to large values of Abs[z]       |
| [image] | "QuantileAbs"         | dark to light shading based on quantiles of Abs[z]             |
| [image] | "CyclicLogAbs"        | cyclic dark to light shading of Log[Abs[z]]                    |
| [image] | "CyclicArg"           | cyclic dark to light shading of Arg[z]                         |
| [image] | "CyclicLogAbsArg"     | cyclic shading of Log[Abs[z]] and Arg[z]                       |
| [image] | "CyclicReImLogAbs"    | dark cycles of Re[z] and Im[z] and light cycles of Log[Abs[z]] |
| [image] | "ShiftedCyclicLogAbs" | cyclic shading of Log[Abs[z]] after a threshold                |
| [image] | None                  | no shading                                                     |

* Functions in ``ColorFunction`` are by default supplied with scaled versions of ``Re[z]``, ``Im[z]``, ``Abs[z]``, ``Arg[z]``.

* 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 $i$ and $j$.

* In explicit ``FrameTicks`` specifications, the tick coordinates are taken to refer to $i$ and $j$.

* ``PlotRange`` can take the following forms:

|                          |                                                                  |
| ------------------------ | ---------------------------------------------------------------- |
| zmax                     | show Abs[zij] values between 0 and zmax                          |
| {zmin, zmax}             | show Abs[zij] values between zmin and zmax                       |
| {rangei, rangej}         | show zij values with i in rangei and j in rangej                 |
| {rangei, rangej, rangez} | show zij values with i in rangei, j in rangej, and zij in rangez |

* The array index ranges ``rangei`` and ``rangej`` can take the following forms:

|            |                                     |
| ---------- | ----------------------------------- |
| {min, max} | include indices between min and max |
| All        | include all indices                 |

* Typical settings for ``PlotLegends`` include:

|                  |                                |
| ---------------- | ------------------------------ |
| None             | no legend                      |
| Automatic        | automatically determine legend |
| Placed[lspec, …] | specify placement for legend   |

* ``Mesh -> True`` draws mesh lines between each cell in the array.

* ``Mesh -> {mi, mj}`` gives mesh specifications for the $i$ and $j$ directions, respectively.

* With the default setting ``Frame -> Automatic``, a frame is drawn only when ``Mesh -> False``.

* For purposes of combining with other graphics, the array element $z_{ij}$ is taken to cover a unit square centered at coordinate position $x=j-1/2$, $y=i_{\text{\textit{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``, $z_{11}$ is centered at ``{xmin, ymax}``.

* With the default setting ``DataRange -> All`` and ``DataReversed -> False``, the array element $a_{ij}$ will be taken to cover a unit square centered at coordinate position $x=j-1/2$, $y=i_{\text{\textit{max}}}-i+1/2$.

### List of all options

|     |     |     |
| --- | --- | --- |
| AlignmentPoint | Center | the default point in the graphic to align with  |
| AspectRatio | Automatic | ratio of height to width  |
| Axes | False | whether to draw axes  |
| AxesLabel | None | axes labels  |
| AxesOrigin | Automatic | where axes should cross  |
| AxesStyle | {}  | style specifications for the axes  |
| Background | None | background color for the plot  |
| BaselinePosition | Automatic | how to align with a surrounding text baseline |
| BaseStyle | {}  | base style specifications for the graphic |
| ClippingStyle | None | how to show cells whose values are clipped |
| ColorFunction | Automatic | how each cell should be colored  |
| ColorFunctionScaling | True | whether to scale the argument to ColorFunction |
| ColorRules | Automatic | rules for determining colors from values  |
| ContentSelectable | Automatic | whether to allow contents to be selected  |
| CoordinatesToolOptions | Automatic | detailed behavior of the coordinates tool |
| DataRange | All | the range of $x$ and $y$ values to assume  |
| DataReversed | False | whether to reverse the order of rows |
| Epilog | {}  | primitives rendered after the main plot  |
| FormatType | TraditionalForm | the default format type for text  |
| Frame | Automatic | whether to draw a frame around the plot  |
| FrameLabel | None | labels for rows and columns |
| FrameStyle | {}  | style specifications for the frame  |
| FrameTicks | None | what ticks to include on the frame  |
| FrameTicksStyle | {}  | style specifications for frame ticks |
| GridLines | None | grid lines to draw  |
| GridLinesStyle | {}  | style specifications for grid lines |
| ImageMargins | 0.  | the margins to leave around the graphic  |
| ImagePadding | All | what extra padding to allow for labels etc. |
| ImageSize | Automatic | the absolute size at which to render the graphic  |
| LabelStyle | {}  | style specifications for labels |
| MaxPlotPoints | Infinity | the maximum number of points to include  |
| Mesh | False | whether to draw a mesh  |
| MeshStyle | GrayLevel[GoldenRatio - 1] | the style to use for a mesh  |
| Method | Automatic | details of graphics methods to use |
| PerformanceGoal | \$PerformanceGoal | aspects of performance to try to optimize |
| PlotLabel | None | an overall label for the plot  |
| PlotLegends | None | legends for datasets |
| PlotRange | All | the range of values to plot  |
| PlotRangeClipping | False | whether to clip at the plot range  |
| PlotRangePadding | Automatic | how much to pad the range of values  |
| PlotRegion | Automatic | the final display region to be filled  |
| PlotTheme | \$PlotTheme | overall theme for the plot |
| PreserveImageOptions | Automatic | whether to preserve image options when displaying new versions of the same graphic |
| Prolog | {}  | primitives rendered before the main plot  |
| RotateLabel | True | whether to rotate y labels on the frame  |
| TargetUnits | Automatic | units to display in the plot |
| Ticks | Automatic | axes ticks  |
| TicksStyle | {}  | style specifications for axes ticks |

---

## Examples (114)

### Basic Examples (6)

Plot an array of numbers:

```wl
In[1]:= ComplexArrayPlot[{{I, 1 + I, 1 - I}, {1, I / 2, 2 + 3I}}]

Out[1]= [image]
```

---

Give explicit color directives to specify colors for individual cells:

```wl
In[1]:= ComplexArrayPlot[{{Black, Orange, 1 - I}, {1, I / 2, 2 + 3I}}]

Out[1]= [image]
```

---

Specify overall color rules:

```wl
In[1]:= ComplexArrayPlot[{{I, 1 + I, 1 - I}, {1, I / 2, 2 + 3I}}, ColorRules -> {1 -> Blue, I -> Yellow}]

Out[1]= [image]
```

---

Include a mesh:

```wl
In[1]:= ComplexArrayPlot[{{I, White, White}, {1, I / 2, 2 + 3I}}, Mesh -> True]

Out[1]= [image]
```

---

Plot a table of data:

```wl
In[1]:= ComplexArrayPlot[RandomComplex[{-1 - I, 1 + I}, {10, 20}]]

Out[1]= [image]
```

---

Use a standard blend as a color function:

```wl
In[1]:= ComplexArrayPlot[RandomComplex[{-1 - I, 1 + I}, {10, 20}], ColorFunction -> "BeachColors"]

Out[1]= [image]
```

### Scope (14)

#### Data (8)

By default, colors change with argument from $-\pi$ (cyan) to $0$ (red) to $\pi$ (cyan):

```wl
In[1]:= ComplexArrayPlot[{{-1 + I, I, 1 + I}, {-1, 0, 1}, {-1 - I, -I, 1 - I}}]

Out[1]= [image]
```

---

By default, colors are lighter for complex numbers with larger moduli:

```wl
In[1]:= ComplexArrayPlot[{{-2 + 2 I, -1 + 2 I, 2 I, 1 + 2 I, 2 + 2 I}, {-2 + I, -1 + I, I, 1 + I, 2 + I}, {-2, -1, 0, 1, 2}, {-2 - I, -1 - I, -I, 1 - I, 2 - I}, {-2 - 2 I, -1 - 2 I, -2 I, 1 - 2 I, 2 - 2 I}}]

Out[1]= [image]
```

---

Unknown, symbolic or missing values are shown dark red:

```wl
In[1]:= ComplexArrayPlot[{{X, Y, Z }, {, 0, 1}, {-1 - I, -I, Null}}]

Out[1]= [image]
```

---

Specify explicit colors for cells:

```wl
In[1]:= ComplexArrayPlot[{{Red, I, 1 + I}, {-1, Green, 1}, {-1 - I, -I, Blue}}]

Out[1]= [image]
```

---

Plot a ragged array, padding on the right:

```wl
In[1]:= ComplexArrayPlot[{{-1 + I}, {-1, 0}, {-1 - I, -I, 1 - I}}]

Out[1]= [image]
```

---

Cells with value ``None`` are rendered like the background:

```wl
In[1]:= ComplexArrayPlot[{{-1 + I, None, 1 + I}, {-1, None, 1}, {-1 - I, None, 1 - I}}]

Out[1]= [image]
```

---

Plot a sparse array:

```wl
In[1]:= ComplexArrayPlot[SparseArray[{{x_, x_} -> 1 + I, ({x_, y_} /; Abs[x - y] < 3) :> RandomComplex[{-1 - I, 1 + I}]}, {10, 10}]]

Out[1]= [image]
```

---

Plot a numeric array:

```wl
In[1]:=
ComplexArrayPlot[RawArray["Complex64", {CompressedData["«419»"], CompressedData["«419»"], 
  CompressedData["«423»"], CompressedData["«419»"], 
  CompressedData["«419»"], CompressedData["«419»"], 
  CompressedData["«423»"], CompressedData["«419»"], 
  CompressedDat ... "«419»"], CompressedData["«419»"], 
  CompressedData["«427»"], CompressedData["«411»"], 
  CompressedData["«415»"], CompressedData["«419»"], 
  CompressedData["«419»"], CompressedData["«415»"], 
  CompressedData["«419»"], CompressedData["«423»"]}]]

Out[1]= [image]
```

#### Presentation (6)

Add a mesh:

```wl
In[1]:= ComplexArrayPlot[{{-1 + I, I, 1 + I}, {-1, 0, 1}, {-1 - I, -I, 1 - I}}, Mesh -> True]

Out[1]= [image]
```

---

Add a legend:

```wl
In[1]:= ComplexArrayPlot[Reverse@Table[real + I imag, {imag, -10, 10}, {real, -10, 10}], PlotLegends -> Automatic]

Out[1]= [image]
```

---

Turn off the default shading:

```wl
In[1]:= ComplexArrayPlot[Reverse@Table[real + I imag, {imag, -10, 10}, {real, -10, 10}], PlotLegends -> Automatic, ColorFunction -> {Automatic, None}]

Out[1]= [image]
```

---

Change the color function:

```wl
In[1]:= ComplexArrayPlot[Reverse@Table[real + I imag, {imag, -10, 10}, {real, -10, 10}], ColorFunction -> {"WatermelonColors", None}]

Out[1]= [image]
```

---

Use shading schemes like ``ComplexPlot`` :

```wl
In[1]:= ComplexArrayPlot[Reverse@Table[real + I imag, {imag, -40, 40}, {real, -40, 40}], ColorFunction -> "ShiftedCyclicLogAbs"]

Out[1]= [image]
```

---

Choose a color function and a shading scheme:

```wl
In[1]:= ComplexArrayPlot[Reverse@Table[real + I imag, {imag, -40, 40}, {real, -40, 40}], ColorFunction -> {"WatermelonColors", "ShiftedCyclicLogAbs"}]

Out[1]= [image]
```

### Options (71)

#### AspectRatio (4)

By default, the ratio of the height to width for the plot is determined automatically:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I]]

Out[1]= [image]
```

---

Use numerical value to specify the height to width ratio:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], AspectRatio -> 1 / 2]

Out[1]= [image]
```

---

Make the height the same as the width with ``AspectRatio -> 1`` :

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], AspectRatio -> 1]

Out[1]= [image]
```

---

``AspectRatio -> Full`` adjusts the height and width to tightly fit inside other constructs:

```wl
In[1]:= plot = ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], AspectRatio -> Full];

In[2]:= {Framed[Pane[plot, {50, 100}]], Framed[Pane[plot, {100, 100}]], Framed[Pane[plot, {100, 50}]]}

Out[2]= {[image], [image], [image]}
```

#### Axes (4)

By default, ``ComplexArrayPlot`` uses a frame instead of axes:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I]]

Out[1]= [image]
```

---

Use axes instead of a frame:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True]

Out[1]= [image]
```

---

Use ``AxesOrigin`` to specify where the axes intersect:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesOrigin -> {0, 0}]

Out[1]= [image]
```

---

Turn each axis on individually:

```wl
In[1]:= {ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> {True, False}], ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> {False, True}]}

Out[1]= {[image], [image]}
```

#### AxesLabel (3)

No axes labels are drawn by default:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True]

Out[1]= [image]
```

---

Place a label on the $y$ axis:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesLabel -> "Label"]

Out[1]= [image]
```

---

Specify axes labels:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesLabel -> {"label 1", "Label 2"}]

Out[1]= [image]
```

#### AxesOrigin (2)

The position of the axes is determined automatically:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesOrigin -> Automatic]

Out[1]= [image]
```

---

Specify an explicit origin for the axes:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesOrigin -> {25, 25}]

Out[1]= [image]
```

#### AxesStyle (4)

Change the style of the axes:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesStyle -> Red]

Out[1]= [image]
```

---

Specify a style for each axis:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesStyle -> {{Thick, Red}, {Thick, Blue}}]

Out[1]= [image]
```

---

Use different styles for the ticks and the axes:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesStyle -> Green, TicksStyle -> Black]

Out[1]= [image]
```

---

Use different styles for the labels and the axes:

```wl
In[1]:= ComplexArrayPlot[Mod[Array[Binomial, {32, 32}, 0], 1 + I], Frame -> False, Axes -> True, AxesStyle -> Green, LabelStyle -> Black]

Out[1]= [image]
```

#### Background (4)

``Background`` is normally visible only around the edges:

```wl
In[1]:= ComplexArrayPlot[{{0, 1, 2, 3}, {I, 1 + I, 2 + I, 3 + I}, {2 I, 1 + 2 I, 2 + 2 I, 3 + 2 I}}, Background -> Blue]

Out[1]= [image]
```

---

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

```wl
In[1]:= ComplexArrayPlot[{{None, 1, 2, 3}, {I, None, 2 + I, 3 + I}, {2 I, 1 + 2 I, None, 3 + 2 I}}, Background -> Blue]

Out[1]= [image]
```

---

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

```wl
In[1]:= ComplexArrayPlot[{{0, 1, 2, 3}, {I, 1 + I, 2 + I, 3 + I}, {2 I, 1 + 2 I, 2 + 2 I, 3 + 2 I}}, Background -> Blue, PlotRange -> {1, 3}]

Out[1]= [image]
```

---

``ClippingStyle`` overrides background color:

```wl
In[1]:= ComplexArrayPlot[{{0, 1, 2, 3}, {I, 1 + I, 2 + I, 3 + I}, {2 I, 1 + 2 I, 2 + 2 I, 3 + 2 I}}, Background -> Blue, PlotRange -> {1, 3}, ClippingStyle -> {White, Black}]

Out[1]= [image]
```

#### ClippingStyle (3)

The default is to show values of $z$ with values outside the $| z|$ plot range in the background color:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^2 + 1, {imag, -5, 5}, {real, -5, 5}], PlotRange -> {3, 20}]

Out[1]= [image]
```

---

Show values outside the plot range in red:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^2 + 1, {imag, -5, 5}, {real, -5, 5}], PlotRange -> {3, 20}, ClippingStyle -> Red]

Out[1]= [image]
```

---

Show low values in black and high values in red:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^2 + 1, {imag, -5, 5}, {real, -5, 5}], PlotRange -> {3, 20}, ClippingStyle -> {Black, Red}]

Out[1]= [image]
```

#### ColorFunction (9)

By default, complex $z$ values are colored by ``Arg[z] ``and shaded by ``Abs[z]`` :

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}]]

Out[1]= [image]
```

---

Turn off the shading based on ``Abs[z]`` :

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunction -> None]

Out[1]= [image]
```

---

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

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunction -> Hue]

Out[1]= [image]
```

---

Use a pure function as the color function:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunction -> (GrayLevel[#4]&)]

Out[1]= [image]
```

---

Use a named color gradient from ``ColorData``:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunction -> "StarryNightColors"]

Out[1]= [image]
```

---

Specify a shading scheme:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -50, 50}, {real, -50, 50}], ColorFunction -> "ShiftedCyclicLogAbs"]

Out[1]= [image]
```

---

Specify a color function and a shading scheme:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -50, 50}, {real, -50, 50}], ColorFunction -> {"DarkRainbow", "CyclicArg"}]

Out[1]= [image]
```

---

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

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -50, 50}, {real, -50, 50}], ColorFunction -> "DarkRainbow", ColorFunctionScaling -> False]

Out[1]= [image]
```

---

Use a color function that colors complex values $z$ by ``Re[z]``, ``Im[z]``, ``Abs[z]`` or ``Arg[z]``:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -50, 50}, {real, -50, 50}], ColorFunction -> Function[{re, im, abs, arg}, Blend[{Red, Green}, abs]]]

Out[1]= [image]
```

#### ColorFunctionScaling (3)

By default, values are scaled to lie between 0 to 1 before applying the color function:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunctionScaling -> True, PlotLegends -> Automatic]

Out[1]= [image]
```

---

Choose to not scale the argument prior to applying the color function:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -20, 20}, {real, -20, 20}], ColorFunctionScaling -> False, PlotLegends -> Automatic]

Out[1]= [image]
```

---

Some color functions are not cyclic so the colors only change in a small band:

```wl
In[1]:= ComplexArrayPlot[Table[(real + I imag)^4 + 1, {imag, -50, 50}, {real, -50, 50}], ColorFunction -> "DarkRainbow", ColorFunctionScaling -> False, PlotLegends -> Automatic]

Out[1]= [image]
```

#### ColorRules (6)

Specify color rules for explicit values:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, -5, 5}, {real, -5, 5}], ColorRules -> {1 -> Black, Gamma[3I] -> White, Gamma[-3I] -> White}]

Out[1]= [image]
```

---

Specify color rules for patterns:

```wl
In[1]:= realQ[z_] := Re[z] == z

In[2]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, -5, 5}, {real, -5, 5}], ColorRules -> {_ ? realQ -> Black}]

Out[2]= [image]
```

---

``ColorFunction`` is used if no color rules apply:

```wl
In[1]:= imaginaryQ[z_] := I Im[z] == z

In[2]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, -5, 5}, {real, -5, 5}], ColorRules -> {_ ? imaginaryQ -> Black}]

Out[2]= [image]
```

---

The array can contain symbolic values:

```wl
In[1]:= ComplexArrayPlot[Transpose[Permutations[{a, b, c}]], ColorRules -> {a -> Red, b -> Yellow, c -> Blue}, Mesh -> True]

Out[1]= [image]
```

---

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

```wl
In[1]:= realQ[z_] := Re[z] == z

In[2]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, -2, 2}, {real, -2, 2}], ColorRules -> {_ ? realQ -> Black, _ -> Yellow}]

Out[2]= [image]
```

---

Rules are used in the order given:

```wl
In[1]:= realQ[z_] := Re[z] == z

In[2]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, -5, 5}, {real, -5, 5}], ColorRules -> {1 -> White, _ ? realQ -> Black}]

Out[2]= [image]
```

#### DataRange (5)

By default, data is plotted at integer coordinates:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic]

Out[1]= [image]
```

---

Specify a range for the data:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataRange -> {{0, 5}, {0, 3}}]

Out[1]= [image]
```

---

Specify a range for the data with a pair of complex numbers:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataRange -> {1 + 2I, 6 + 5I}]

Out[1]= [image]
```

---

Specify the bottom-left corner of the data range:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataRange -> {0, All}]

Out[1]= [image]
```

---

Specify the top-right corner of the data range:

```wl
In[1]:= ComplexArrayPlot[Table[Gamma[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataRange -> {All, 0}]

Out[1]= [image]
```

#### DataReversed (4)

Reverse the order of rows:

```wl
In[1]:= ComplexArrayPlot[Table[ArcCos[real + I imag], {imag, 0, 3}, {real, 0, 5}], DataReversed -> True]

Out[1]= [image]
```

---

The frame ticks give the original row numbers:

```wl
In[1]:= ComplexArrayPlot[Table[ArcCos[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataReversed -> True]

Out[1]= [image]
```

---

Reverse the order of rows and columns:

```wl
In[1]:= ComplexArrayPlot[Table[ArcCos[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataReversed -> {True, True}]

Out[1]= [image]
```

---

Reverse the order of columns:

```wl
In[1]:= ComplexArrayPlot[Table[ArcCos[real + I imag], {imag, 0, 3}, {real, 0, 5}], FrameTicks -> Automatic, DataReversed -> {False, True}]

Out[1]= [image]
```

#### Epilog (3)

Use ``Epilog`` to superimpose other graphics:

```wl
In[1]:= ComplexArrayPlot[RandomComplex[{-1 - I, 1 + I}, {5, 5}], Epilog -> Disk[]]

Out[1]= [image]
```

---

``Epilog`` uses the standard ``Graphics`` coordinate system:

```wl
In[1]:= ComplexArrayPlot[RandomComplex[{-1 - I, 1 + I}, {5, 5}], Epilog -> Disk[{3, 3}, 1]]

Out[1]= [image]
```

---

The graphics can be translucent:

```wl
In[1]:= ComplexArrayPlot[RandomComplex[{-1 - I, 1 + I}, {5, 5}], Epilog -> {Opacity[0.5], Disk[{3, 3}, 1]}]

Out[1]= [image]
```

#### MaxPlotPoints (1)

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

```wl
In[1]:= ComplexArrayPlot[Partition[Table[PowerMod[1 + 3I, k, 7], {k, 0, 2^14 - 1}], 2^7]]

Out[1]= [image]

In[2]:= ComplexArrayPlot[Partition[Table[PowerMod[1 + 3I, k, 7], {k, 0, 2^14 - 1}], 2^7], MaxPlotPoints -> 50]

Out[2]= [image]
```

#### Mesh (4)

Insert mesh lines between all cells:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> All]

Out[1]= [image]
```

---

Insert 1 row mesh line and 3 column mesh lines:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> {1, 3}]

Out[1]= [image]
```

---

Insert mesh lines around the first 4 columns:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> {None, Range[4]}]

Out[1]= [image]
```

---

Specify styles for the mesh lines:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> {None, Table[{i, GrayLevel[i / 8]}, {i, 0, 8}]}]

Out[1]= [image]
```

#### MeshStyle (2)

Style the mesh lines:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> All, MeshStyle -> Directive[Black, Thick]]

Out[1]= [image]
```

---

Style the row lines differently than the column lines:

```wl
In[1]:= ComplexArrayPlot[Partition[Table[k Exp[2π I k / 32], {k, 0, 31}], 8], Mesh -> All, MeshStyle -> {Directive[Black, Thick], White}]

Out[1]= [image]
```

#### PlotLegends (5)

No legend is used by default:

```wl
In[1]:= ComplexArrayPlot[Array[(#1 + I #2)^3&, {10, 10}, 0]]

Out[1]= [image]
```

---

Generate a legend automatically:

```wl
In[1]:= ComplexArrayPlot[Array[(#1 + I #2)^3&, {10, 10}, 0], PlotLegends -> Automatic]

Out[1]= [image]
```

---

``PlotLegends`` automatically picks up a named ``ColorFunction`` :

```wl
In[1]:= ComplexArrayPlot[Array[(#1 + I #2)^3&, {10, 10}, 0], PlotLegends -> Automatic, ColorFunction -> {"TemperatureMap", "CyclicLogAbsArg"}]

Out[1]= [image]
```

---

``PlotLegends`` does not pick up a user-defined ``ColorFunction``, but the user can still construct an appropriate legend:

```wl
In[1]:= Legended[ComplexArrayPlot[Array[(#1 + I #2)^3&, {10, 10}, 0], PlotLegends -> Automatic, ColorFunction -> {(RGBColor[#4, 0.5, 0]&), None}], BarLegend[{(RGBColor[#, 0.5, 0]&), {-π, π}}]]

Out[1]= [image]
```

---

Use ``Placed`` to change the location of the legend:

```wl
In[1]:= ComplexArrayPlot[Array[(#1 + I #2)^3&, {10, 10}, 0], PlotLegends -> Placed[Automatic, Below]]

Out[1]= [image]
```

#### PlotRange (4)

Plot all elements:

```wl
In[1]:= ComplexArrayPlot[Array[I#1Sin[#1 + #2]&, {5, 15}]]

Out[1]= [image]
```

---

Plot values of $z$ for which ``1 ≤ Abs[z] ≤ 2`` :

```wl
In[1]:= ComplexArrayPlot[Array[I#1Sin[#1 + #2]&, {5, 15}], PlotRange -> {1, 2}]

Out[1]= [image]
```

---

Plot values of $z$ for which ``Abs[z] ≤ 2`` :

```wl
In[1]:= ComplexArrayPlot[Array[I#1Sin[#1 + #2]&, {5, 15}], PlotRange -> 2]

Out[1]= [image]
```

---

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

```wl
In[1]:= ComplexArrayPlot[Array[I#1Sin[#1 + #2]&, {5, 15}], PlotRange -> {{2, 4}, All, {0, 2}}]

Out[1]= [image]
```

#### PlotTheme (1)

Use a theme with detailed ticks and a legend:

```wl
In[1]:= ComplexArrayPlot[Array[(9#1 + 4I #2)^3&, {10, 10}], PlotTheme -> "Detailed"]

Out[1]= [image]
```

Move the legend below the plot:

```wl
In[2]:= ComplexArrayPlot[Array[(9#1 + 4I #2)^3&, {10, 10}], PlotTheme -> "Detailed", PlotLegends -> Placed[Automatic, Below]]

Out[2]= [image]
```

### Applications (18)

#### Fourier Transforms (6)

Generate a pure discrete two-dimensional sinusoid:

```wl
In[1]:=
n = 16;
{f1, f2} = {3, 5};
data = Table[Sin[(2π f1 x/n)]Sin[(2π f2 y/n)], {x, 0, n - 1}, {y, 0, n - 1}];
```

Compute the two-dimensional Fourier transform:

```wl
In[2]:= fft = Chop[Fourier[data]];
```

Display the original data and its Fourier transform. In the second plot, the bright square in row 4 and column 6 (measured from the top-left corner) tells us that the corresponding frequencies are 3 and 5, respectively:

```wl
In[3]:= {ArrayPlot[data], ComplexArrayPlot[fft, Mesh -> All]}

Out[3]= {[image], [image]}
```

Generate a linear combination of discrete sinusoids:

```wl
In[4]:= data2 = Table[Sin[(2π f1 x/n)]Sin[(2π f2 y/n)] + 3Sin[(2π f2 x/n)] - 8Sin[(2π f1 y/n)], {x, 0, n - 1}, {y, 0, n - 1}];
```

Identify the component frequencies in the Fourier transform:

```wl
In[5]:= ComplexArrayPlot[Chop@Fourier[data2], Mesh -> All]

Out[5]= [image]
```

---

Display two-dimensional data and its Fourier transform:

```wl
In[1]:= data = 1 - ImageData[Binarize@Rasterize["I"]];

In[2]:= {ArrayPlot[data], ComplexArrayPlot[Fourier[data]]}

Out[2]= {[image], [image]}
```

---

Use ``ColorRules`` to threshold a Fourier transform:

```wl
In[1]:= data = ImageData[ImageResize[ColorConvert[[image], "Grayscale"], {64, 64}]];

In[2]:= {ArrayPlot[data], ComplexArrayPlot[Fourier[data], ColorRules -> {_ ? (Abs[#] < 0.2&) -> Black}, ColorFunction -> None]}

Out[2]= {[image], [image]}
```

---

Display only the top-left quarter of the Fourier transform:

```wl
In[1]:= data = ImageData[Binarize[[image]]];

In[2]:= ComplexArrayPlot[Take[#, 34]& /@ Take[Fourier[data], 34], ColorFunction -> "BlueGreenYellow", PlotLegends -> Automatic]

Out[2]= [image]
```

---

Model the intensity of light diffracted by a small circular aperture:

```wl
In[1]:= data = Quiet@Table[((2BesselJ[1, Sqrt[x^2 + y^2]]/Sqrt[x^2 + y^2]))^2, {x, -30, 30}, {y, -30, 30}] /. Indeterminate -> 1;
```

Display the diffraction pattern and its Fourier transform:

```wl
In[2]:= {ArrayPlot[Log@data], ComplexArrayPlot[Fourier[data]]}

Out[2]= {[image], [image]}
```

---

Create data and modify it by shifting the columns left:

```wl
In[1]:=
data = CrossMatrix[10];
data2 = RotateLeft[#, 10]& /@ data;
```

The magnitude of Fourier transforms are graphed, but that does not reveal potentially useful phase information. Observe the extra information in the middle plot:

```wl
In[2]:= {ArrayPlot[data, PlotLabel -> "Original Data"], ComplexArrayPlot[Fourier[data], PlotLabel -> "Fourier Transform"], ArrayPlot[Abs[Fourier@data], PlotLabel -> "|Fourier Transform|"]}

Out[2]= {[image], [image], [image]}
```

Note the change in the ``ComplexArrayPlot`` and the lack of change in the ``ArrayPlot`` of the Fourier transform:

```wl
In[3]:= {ArrayPlot[data2, PlotLabel -> "Original Data"], ComplexArrayPlot[Fourier[data2], PlotLabel -> "Fourier Transform"], ArrayPlot[Abs[Fourier@data2], PlotLabel -> "|Fourier Transform|"]}

Out[3]= {[image], [image], [image]}
```

#### Matrix Representations (3)

Plot a sparse matrix with complex entries:

```wl
In[1]:= m = SparseArray[{{30, _} -> 1, {_, 30} -> -1, {j_, k_} /; Abs[j - k] ≤ 1 :> Exp[2π I k / 50]}, {50, 50}];

In[2]:= ComplexArrayPlot[m, ColorRules -> {0 -> Black}, ColorFunction -> None]

Out[2]= [image]
```

---

Plot a random complex-valued matrix:

```wl
In[1]:= m = RandomComplex[{-1 - I, 1 + I}, {8, 8}];

In[2]:= ComplexArrayPlot[m]

Out[2]= [image]
```

Visually verify that the matrix is diagonalized:

```wl
In[3]:= p = Transpose[Eigenvectors[m]];

In[4]:= ComplexArrayPlot[Chop[Inverse[p].m.p], ColorRules -> {0 -> White}]

Out[4]= [image]
```

Visualize the matrices in a matrix factorization:

```wl
In[5]:= {q, r} = QRDecomposition[m];

In[6]:= ComplexArrayPlot /@ {q, r}

Out[6]= {[image], [image]}
```

---

Visually compare Kronecker products:

```wl
In[1]:= ComplexArrayPlot[KroneckerProduct[PauliMatrix[#[[1]]], PauliMatrix[#[[2]]]], ColorRules -> {0 -> White}, ColorFunction -> None, PlotLabel -> Subscript[σ, #[[1]]]⊗Subscript[σ, #[[2]]]]& /@ Subsets[Range[3], {2}]

Out[1]= {[image], [image], [image]}

In[2]:= ComplexArrayPlot[KroneckerProduct[PauliMatrix[#[[2]]], PauliMatrix[#[[1]]]], ColorRules -> {0 -> White}, ColorFunction -> None, PlotLabel -> Subscript[σ, #[[2]]]⊗Subscript[σ, #[[1]]]]& /@ Subsets[Range[3], {2}]

Out[2]= {[image], [image], [image]}
```

#### Basins of Attraction (2)

Define a complex valued function with roots at 1, ``±E^2π I / 3`` :

```wl
In[1]:= f[z_] := z^3 - 1
```

Compute the corresponding Newton map:

```wl
In[2]:= newtonMapf = Compile[{{z, _Complex}}, Evaluate[z - (f[z]/f'[z])]];
```

Compute approximations to the roots of $f(z)$ for various starting values:

```wl
In[3]:= rootsf = Quiet@Reverse[Table[Nest[newtonMapf, 1.0x + I y, 100], {y, -1, 1, 0.01}, {x, -1, 1, 0.01}]];//Timing

Out[3]= {0.953125, Null}
```

Display the basins of attraction:

```wl
In[4]:= ComplexArrayPlot[rootsf, ColorFunction -> None, PlotLegends -> SwatchLegend[{LABColor[0.5487947278149338, 0.629271353261171, 0.4277070533203531], LABColor[0.740301849178597, -0.5551479480848852, 0.5722452976336212], LABColor[0.4836757194298422, 0.3968716772040611, -0.7197934077503745]}, {1, Exp[2π I / 3], Exp[-2π I / 3]}]]

Out[4]= [image]
```

Define a complex-valued function with an infinite number of roots, $\sqrt[3]{n \pi +1}$, $\sqrt[3]{n \pi +1} \exp \left(\pm \frac{2}{3} \pi  i\right)$ :

```wl
In[5]:= g[z_] := Sin[z^3 - 1]
```

Compute the corresponding Newton map:

```wl
In[6]:= newtonMapg = Compile[{{z, _Complex}}, Evaluate[z - (g[z]/g'[z])]];
```

Note that the roots only have three distinct argument values, $0$ and $\pm \frac{2\pi }{3}$ :

```wl
In[7]:= ComplexListPlot[Table[z /. NSolve[z^3 - 1 == n π, z], {n, 0, 10}]]

Out[7]= [image]
```

Compute approximations to the roots of $g(z)$ for various starting values:

```wl
In[8]:= rootsg = Quiet@Reverse[Table[Nest[newtonMapg, 1.0x + I y, 100], {y, -1, 1, 0.005}, {x, -1, 1, 0.005}]];
```

Display the basins of attraction, using shading to highlight the dependence on the modulus of the roots:

```wl
In[9]:= ComplexArrayPlot[rootsg, ColorFunction -> "CyclicLogAbs"]

Out[9]= [image]
```

---

Define a complex-valued function with roots at 1, ``±E^2π I / 3`` :

```wl
In[1]:= f[z_] := z^3 - 1
```

Newton's method has quadratic convergence, but Halley's method has cubic convergence:

```wl
In[2]:= halleyMapf = Compile[{{z, _Complex}}, Evaluate[z - (2f[z] Derivative[1][f][z]/2Derivative[1][f][z]^2 - f[z] Derivative[2][f][z])]];
```

Compute approximations to the roots of $f(z)$ for various starting values:

```wl
In[3]:= rootsf = Quiet@Table[Nest[halleyMapf, 1.0x + I y, 10], {y, -2, 2, 0.01}, {x, -2, 2, 0.01}];
```

Display the basins of attraction for Halley's method:

```wl
In[4]:= ComplexArrayPlot[rootsf, ColorFunction -> None, PlotLegends -> SwatchLegend[{LABColor[0.5487947278149338, 0.629271353261171, 0.4277070533203531], LABColor[0.740301849178597, -0.5551479480848852, 0.5722452976336212], LABColor[0.4836757194298422, 0.3968716772040611, -0.7197934077503745]}, {1, Exp[2π I / 3], Exp[-2π I / 3]}]]

Out[4]= [image]
```

#### Matrix Spectra (2)

Display eigenvalues from a two-parameter family of matrices:

```wl
In[1]:= eigs = Table[Eigenvalues[{{1, a}, {1, b}}], {b, -10, 10}, {a, -10, 10}];

In[2]:=
{ComplexArrayPlot[Map[First, eigs, {2}]], 
	ComplexArrayPlot[Map[Last, eigs, {2}]]}

Out[2]= {[image], [image]}
```

---

Define a matrix:

```wl
In[1]:=
m = (⁠|   |       |   |   |
| - | ----- | - | - |
| 0 | 1     | 0 | 0 |
| 0 | 0     | 1 | 0 |
| 0 | 0     | 0 | 1 |
| 0 | 1 - I | I | 0 |⁠);
```

Compute its eigenvalues:

```wl
In[2]:= Eigenvalues[m]

Out[2]= {-1 - I, I, 1, 0}
```

The ϵ-pseudospectrum of the matrix $m$ is the set of values $\lambda$ in the complex plane for which the norm of ``(m - λ I)^-1`` is greater than $$\frac{1}{\epsilon }$$. Graph the ϵ-pseudospectra for ``ϵ = 1, 1 / 2, 1 / 4, 1 / 8, 1 / 16, 1 / 32`` and note the eigenvalues at the white dots:

```wl
In[3]:= ContourPlot[Norm[Inverse[1.0m - (x + I y) IdentityMatrix[4]], 2], {x, -2, 2}, {y, -2, 2}, Contours -> {1, 2, 4, 8, 16, 32}, PlotRange -> {0, 64}, ColorFunction -> "CMYKColors"]

Out[3]= [image]
```

If the largest eigenvalue is used instead of the norm of ``(m - λ I)^-1``, then argument information can be added:

```wl
In[4]:=
data = Reverse@Table[First@Eigenvalues[Quiet@Inverse[m - (x + I y) IdentityMatrix[4, SparseArray]], 1], {y, -2, 2, 0.01}, {x, -2, 2, 0.01}];
ComplexArrayPlot[data]

Out[4]= [image]
```

Create a Toeplitz matrix:

```wl
In[5]:=
t = ToeplitzMatrix[PadRight[{1, -1}, 10], PadRight[{1, 1, 1, 1}, 10]];
MatrixForm[t]

Out[5]//MatrixForm=
(⁠|    |    |    |    |    |    |    |    |    |   |
| -- | -- | -- | -- | -- | -- | -- | -- | -- | - |
| 1  | 1  | 1  | 1  | 0  | 0  | 0  | 0  | 0  | 0 |
| -1 | 1  | 1  | 1  | 1  | 0  | 0  | 0  | 0  | 0 |
| 0  | -1 | 1  | 1  | 1  | 1  | 0  | 0  |  ...  | 0  | 0  | -1 | 1  | 1  | 1  | 1  | 0 |
| 0  | 0  | 0  | 0  | 0  | -1 | 1  | 1  | 1  | 1 |
| 0  | 0  | 0  | 0  | 0  | 0  | -1 | 1  | 1  | 1 |
| 0  | 0  | 0  | 0  | 0  | 0  | 0  | -1 | 1  | 1 |
| 0  | 0  | 0  | 0  | 0  | 0  | 0  | 0  | -1 | 1 |⁠)
```

Make a plot similar to an ϵ-pseudospectral plot:

```wl
In[6]:=
data = Reverse@Table[First@Eigenvalues[Inverse[t - (x + I y) IdentityMatrix[10, SparseArray]], 1], {y, -2.5, 2.5, 0.01}, {x, -2.5, 2.5, 0.01}];//Timing
ComplexArrayPlot[data, ColorFunction -> "QuantileAbs"]

Out[6]= [image]
```

Use a named matrix:

```wl
In[7]:= mat = ExampleData[{"Matrix", "WEST0067"}];
```

Make a graph similar to a spectral portrait:

```wl
In[8]:=
data = Table[First@Eigenvalues[Inverse[mat - (x + I y) IdentityMatrix[Length[mat], SparseArray]], 1], {y, -2, 2, 0.05}, {x, -2, 2, 0.05}];
ComplexArrayPlot[data, ColorFunction -> {"DarkRainbow", "GlobalAbs"}]

Out[8]= [image]
```

#### Iterated Systems (3)

Visualize complex cellular automata:

```wl
In[1]:= ComplexArrayPlot[CellularAutomaton[{{a_, b_} -> a b}, {{Exp[2π I / 3]}, 1}, 3^4 - 1], ColorFunction -> None, ColorRules -> {1 -> White}]

Out[1]= [image]

In[2]:= ComplexArrayPlot[CellularAutomaton[{{a_, b_} -> a b}, {{Exp[π I / 4]}, 1}, 2^8 - 1], ColorFunction -> None, ColorRules -> {1 -> White}]

Out[2]= [image]

In[3]:= ComplexArrayPlot[CellularAutomaton[{{a_, b_} -> a  - b}, {{Exp[π I / 4]}, 1}, 20], ColorFunction -> None, ColorRules -> {1 -> Black, 0 -> White}]

Out[3]= [image]
```

---

Compute iterates of a complex-valued function:

```wl
In[1]:=
c = 1.0 + I;
data = NestList[#^2 + c&, 0.0, 50];
```

Display the data on a width of 10:

```wl
In[2]:= ComplexArrayPlot[Partition[data, 10]]

Out[2]= [image]
```

The iterates appear to converge for a different constant:

```wl
In[3]:=
c = (1.0 + I/3);
data = NestList[#^2 + c&, 0.0, 50];

In[4]:= ComplexArrayPlot[Partition[data, 10]]

Out[4]= [image]
```

Iterates are periodic for carefully chosen constants:

```wl
In[5]:=
Clear[c];
c = c /. Solve[Nest[#^2 + c&, 0, 7] == 0, c][[20]];
data = NestList[#^2 + c&, 0.0, 50]//Chop;

In[6]:= ComplexArrayPlot[Partition[data, 10]]

Out[6]= [image]
```

---

Let $f(z)=c z (z-1)$ be the logistic function with a complex coefficient $c$. Consider the sequence $a_0=1.1$, $a_n=f\left(a_{n-1}\right)$ for $n\geq 1$. Approximate the values of $c$ for which $a_n$ is unbounded and visualize the region:

```wl
In[1]:=
a = Reverse@Table[Quiet@FixedPoint[(c1 + I c2)#(1 - #)&, 1.1, 20], {c2, -2, 2, 0.02}, {c1, -2, 2, 0.02}];//Timing
a = a /. {z_ ? NumericQ :> If[Abs[z] < 1000, z, 0]};
Quiet@ComplexArrayPlot[a, ColorRules -> {0 -> Black}]

Out[1]= [image]
```

#### Miscellaneous (2)

Highlight Gaussian primes in black:

```wl
In[1]:= gaussianPrimeQ[c_] := PrimeQ[c, GaussianIntegers -> True]

In[2]:=
n = 20;
pts = Outer[#1 + I #2&, Range[-n, n], Range[-n, n]];
ComplexArrayPlot[pts, ColorRules -> {_ ? gaussianPrimeQ -> Black}, DataRange -> {{-n, n}, {-n, n}}, FrameTicks -> All]

Out[2]= [image]
```

---

Plot a Fourier matrix:

```wl
In[1]:=
n = 32;
mat = Table[(1/Sqrt[n])Exp[2.0π I j k / n], {j, 0, n - 1}, {k, 0, n - 1}];

In[2]:= ComplexArrayPlot[mat, ColorFunction -> None]

Out[2]= [image]
```

Highlight the purely real and purely imaginary entries in black and gray, respectively:

```wl
In[3]:= ComplexArrayPlot[Chop@mat, ColorRules -> {z_ /; Re[z] == 0 -> Gray, z_ /; Im[z] == 0 -> Black}]

Out[3]= [image]
```

### Properties & Relations (5)

``ComplexArrayPlot`` colors complex values by their arguments and shades by their moduli like ``ComplexPlot`` :

```wl
In[1]:= f[z_] := I Sin[z^2 + 1]

In[2]:= data = Reverse@Table[f[x + I y], {y, -2, 2, 0.05}, {x, -2, 2, 0.05}];

In[3]:= {ComplexArrayPlot[Reverse@Table[f[x + I y], {y, -2, 2, 0.05}, {x, -2, 2, 0.05}]], ComplexPlot[f[z], {z, -2 - 2I, 2 + 2I}]}

Out[3]= {[image], [image]}
```

---

``ComplexArrayPlot`` is similar to ``ArrayPlot`` and ``MatrixPlot`` applied to the arguments of the complex values:

```wl
In[1]:= data = Table[Sin[x + I y], {y, -2, 2, 0.25}, {x, -2, 2, 0.25}];

In[2]:= {ComplexArrayPlot[data], ArrayPlot[Arg[data], ColorFunction -> (Hue[# + 0.5]&)], MatrixPlot[Arg[data], ColorFunction -> (Hue[# + 0.5]&)]}

Out[2]= {[image], [image], [image]}
```

---

``Grid`` arranges elements the same way as ``ComplexArrayPlot`` :

```wl
In[1]:= data = {{0, Exp[I π / 4], I, Exp[3I π / 4]}, {-1, Exp[-3I π / 4], -I, Exp[-I π / 4]}};

In[2]:= Grid[data]

Out[2]=
|    |              |    |             |
| -- | ------------ | -- | ----------- |
| 0  | E^(I π/4)    | I  | E^(3 I π/4) |
| -1 | E^-(3 I π/4) | -I | E^-(I π/4)  |

In[3]:= ComplexArrayPlot[data, PlotLegends -> Automatic, ColorFunction -> None]

Out[3]= [image]
```

---

``Raster`` arranges elements upside down relative to ``ComplexArrayPlot`` :

```wl
In[1]:= data = {{0, Exp[I π / 4], I, Exp[3I π / 4]}, {-1, Exp[-3I π / 4], -I, Exp[-I π / 4]}};

In[2]:= {ComplexArrayPlot[data, ColorFunction -> {(GrayLevel[#4]&), None}], Graphics[Raster[(Arg[data] + π/2π)]]}

Out[2]= {[image], [image]}
```

---

``ArrayPlot3D`` can be used for 3D arrays of data:

```wl
In[1]:= ArrayPlot3D[RandomInteger[1, {3, 4, 5}]]

Out[1]= [image]
```

## See Also

* [`ArrayPlot`](https://reference.wolfram.com/language/ref/ArrayPlot.en.md)
* [`ComplexPlot`](https://reference.wolfram.com/language/ref/ComplexPlot.en.md)
* [`ComplexPlot3D`](https://reference.wolfram.com/language/ref/ComplexPlot3D.en.md)
* [`ComplexListPlot`](https://reference.wolfram.com/language/ref/ComplexListPlot.en.md)
* [`MatrixPlot`](https://reference.wolfram.com/language/ref/MatrixPlot.en.md)
* [`ReliefPlot`](https://reference.wolfram.com/language/ref/ReliefPlot.en.md)
* [`ListDensityPlot`](https://reference.wolfram.com/language/ref/ListDensityPlot.en.md)
* [`Grid`](https://reference.wolfram.com/language/ref/Grid.en.md)
* [`GraphicsGrid`](https://reference.wolfram.com/language/ref/GraphicsGrid.en.md)
* [`SparseArray`](https://reference.wolfram.com/language/ref/SparseArray.en.md)

## Related Guides

* [Complex Visualization](https://reference.wolfram.com/language/guide/ComplexVisualization.en.md)

## History

* [Introduced in 2020 (12.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn122.en.md)