Skip to content

Plotting: 2D

matplotlib-backed. All of these return matplotlib objects, so you can keep styling them.

complexplorer.plot

plot(domain: Domain | None = None, func: Callable | None = None, z: ndarray | None = None, f: ndarray | None = None, resolution: int = 400, cmap: Colormap | None = None, ax: Axes | None = None, title: str | None = None, filename: str | None = None, legend: bool = False) -> Axes

Plot complex function as domain coloring.

This function provides a convenient interface for plotting complex functions using domain coloring. Either provide a domain and function, or directly provide the mesh arrays z and f.

Parameters:

Name Type Description Default
domain Domain

Domain object. If None, z must be provided.

None
func callable

Complex function. If None, f must be provided.

None
z ndarray

2D array of complex domain values.

None
f ndarray

2D array of complex codomain values.

None
resolution int

Resolution (number of points along longest edge).

400
cmap Colormap

Colormap to use. Defaults to enhanced phase portrait.

None
ax Axes

Matplotlib axes to plot on.

None
title str

Plot title.

None
filename str

If provided, save the figure to this file (honored whether or not ax is supplied).

None
legend bool

If True, draw a phase-wheel legend inset (the unit disk colored by the active colormap) in the upper-right corner.

False

Returns:

Type Description
Axes

The matplotlib axes drawn on (always returned).

Examples:

>>> # Using domain and function
>>> domain = Rectangle(4, 4)
>>> plot(domain, lambda z: z**2, resolution=200)
>>> # Using pre-computed arrays
>>> z = domain.mesh(200)
>>> f = z**2
>>> plot(z=z, f=f)

complexplorer.pair_plot

pair_plot(domain: Domain | None = None, func: Callable | None = None, z: ndarray | None = None, f: ndarray | None = None, resolution: int = 400, cmap: Colormap | None = None, title: str | None = None, figsize: tuple[float, float] = (10, 5), filename: str | None = None, legend: bool = False) -> Figure

Plot domain and codomain side by side.

Parameters:

Name Type Description Default
domain Domain

Domain object. If None, z must be provided.

None
func callable

Complex function. If None, f must be provided.

None
z ndarray

2D array of complex domain values.

None
f ndarray

2D array of complex codomain values.

None
resolution int

Resolution (number of points along longest edge).

400
cmap Colormap

Colormap to use. Defaults to enhanced phase portrait.

None
title str

Overall figure title.

None
figsize tuple

Figure size (width, height).

(10, 5)
filename str

If provided, save figure to this file.

None
legend bool

If True, draw a phase-wheel legend inset on the codomain panel.

False

Returns:

Type Description
Figure

The matplotlib figure.

complexplorer.riemann_chart

riemann_chart(func: Callable, domain: Domain | None = None, resolution: int = 100, show_south_hemisphere: bool = True, project_from_north: bool = True, cmap: Colormap | None = None, ax: Axes | None = None, margin: float = 0.05, unit_circle_width: float = 1.0) -> Axes

Plot phase portrait on Riemann hemisphere.

This function visualizes a complex function on either hemisphere of the Riemann sphere using stereographic projection.

Parameters:

Name Type Description Default
func callable

Complex function to visualize.

required
domain Domain

If provided, chart samples outside this domain are painted with the colormap's out-of-domain color.

None
resolution int

Resolution for the mesh.

100
show_south_hemisphere bool

If True, show lower hemisphere; else upper.

True
project_from_north bool

If True, use north pole projection (standard).

True
cmap Colormap

Colormap to use.

None
ax Axes

Matplotlib axes to plot on.

None
margin float

Margin around unit disk (0 to 0.5).

0.05
unit_circle_width float

Width of unit circle highlight.

1.0

Returns:

Type Description
Axes

The matplotlib axes used.

complexplorer.riemann_hemispheres

riemann_hemispheres(func: Callable, title: str | None = None, resolution: int = 400, margin: float = 0.05, unit_circle_width: float = 1.0, figsize: tuple[float, float] = (12, 4), filename: str | None = None) -> Figure

Plot both hemispheres of the Riemann sphere.

Parameters:

Name Type Description Default
func callable

Complex function to visualize.

required
title str

Overall figure title.

None
resolution int

Resolution for the mesh.

400
margin float

Margin around unit disk.

0.05
unit_circle_width float

Width of unit circle highlight.

1.0
figsize tuple

Figure size (width, height).

(12, 4)
filename str

If provided, save figure to this file.

None

Returns:

Type Description
Figure

The matplotlib figure.