Skip to content

Complexplorer

Complexplorer turns a complex function into something you can look at — and, if you want, hold. It draws phase portraits, lifts them into 3D analytic landscapes, wraps them onto the Riemann sphere, unfolds multivalued functions onto their Riemann surfaces, and exports any of it as an STL you can print.

The six things complexplorer makes

pip install complexplorer
import complexplorer as cp

cp.plot(
    cp.Rectangle(4, 4),
    lambda z: (z**2 - 1) / (z**2 + 1),
    cmap=cp.Phase(phase_sectors=6, auto_scale_r=True),
    legend=True,
)

That is the whole first step. Installation and a first portrait takes it slowly.

The idea, in six pictures

A portrait is a decodable picture, not a pretty one

2D phase portrait of (z^2-1)/(z^2+1) with a phase-wheel legend inset

Hue is the phase of f(z) and the shaded cells are its contour bands, so zeros and poles read as opposite winding directions. The inset legend is the same colormap applied to the identity map, which is what makes the picture decodable.

→ Reading a phase portrait

Height adds magnitude without changing the colours

Side-by-side 2D phase portrait and 3D analytic landscape of the same function

The same function twice: flat, then with |f(z)| lifted into height. The zeros sink and the poles rise, while the colours stay put — the landscape adds magnitude without changing what the hue means.

→ 3D landscapes and the Riemann sphere

The sphere and the surface are different objects

Riemann sphere of 1/z beside the two-sheeted Riemann surface of the square root

Two different objects that are easy to confuse. The sphere compactifies the plane so one single-valued function can include the point at infinity. The surface is the two-sheeted cover on which the multivalued sqrt(z) becomes single-valued.

→ Riemann surfaces

A domain is a set you can do arithmetic on

Phase portrait of 1/z on a peanut-shaped union of two disks with a disk removed around the pole

The outline is two overlapping disks unioned together, with a third punched out of the middle. Excluding a neighbourhood of the pole is not cosmetic: it keeps the huge values near z = 0 out of the sampling entirely.

→ Domains and colormaps

Engineering mode is the same machinery, aimed

Four-panel engineering figure: transfer portrait, pole-zero map, Nyquist plot and Bode magnitude and phase for a notch filter

One stable transfer function in four views. The zeros sit exactly on the jω axis at ±2j — the notch — while the poles stay inside the left half-plane. The portrait shows where they are; Bode and Nyquist show what they do to a signal.

→ Engineering mode

The last step is a physical object

Three panels: Riemann relief render, untextured STL mesh, and the printed ornament

The relief is the mathematics, the mesh is the geometry that survives losing the colour, and the print is the object on a desk. Ten poles become ten spikes around the central zero.

→ STL export and the physical workflow

Where to go next

If you want to Start here
Install it and draw something Installation and a first portrait
Understand what you are looking at Reading a phase portrait
See everything the library can draw Gallery
Look up a function API reference
Drive it from a terminal Command line
Upgrade from 1.x or 2.x Migration guide

Every image on this site is generated by python examples/showcase.py, from the recipes recorded in examples/gallery/showcase.json — including the ones above.