fredrikj.net / blog /

Phaseful plots

March 12, 2016

I've added a new color function to the cplot function in mpmath as well as the complex_plot example program in Arb. With the old scheme (which is still default), the phase is rendered as hue and the magnitude is rendered as brightness. With the new (optional) scheme, only the phase is rendered. Positive reals are white, negative reals are black, complex numbers in the upper half plane are orange/gold, and complex numbers in the lower half plane are blue.

Here is the Riemann zeta function on $[-20,20] + [-20,40]i$ with the new style (left) and the default style (right):

New style plot of the Riemann zeta function Default style plot of the Riemann zeta function

More simply, $\sin(z)$ on $[-5,5] + [-5,5]i$ with the new style (left) and the default style (right):

New style plot of the sine function Default style plot of the sine function

The Jacobi theta function $\theta_1(0.6+0.4i, \tau)$ on $[-2,2] + [0,1]i$ with the new style (top) and the default style (bottom):

New style plot of a Jacobi theta function Default style plot of a Jacobi theta function

Finally, new and default style plots of the error function and the gamma function on $[-5,5] + [-5,5]i$:

New style plot of the error function Default style plot of the error function
New style plot of the gamma function Default style plot of the gamma function

The new color scheme conveys less information than the default scheme, but sometimes leads to more aesthetically pleasing images. The black and white level curves (where the plotted function is purely real-valued) stand out clearly, and zeros/poles are easy to identify as the points where black and white meet.

For reference, the new color scheme consists of interpolating linearly between the following values:

$\arg(z) / \pi$ R G B
-1.00.00.00.0
-0.950.10.20.5
-0.50.00.51.0
-0.050.40.80.8
0.01.01.01.0
+0.051.00.90.3
+0.50.90.50.0
+0.950.70.10.0
+1.00.00.00.0

You could do the coloring in many other ways. The Wikipedia article on domain coloring contains some ideas and many nice links. In mpmath, the user can easily supply their own color function, but it would be nice to have a few more optional schemes built-in.



fredrikj.net  |  Blog index  |  RSS feed  |  Follow me on Mastodon  |  Become a sponsor