Function Repository Resource:

ComplexBubblePlot

Source Notebook

Visualize a complex function as an array of bubbles

Contributed by: Jan Mangaldan

ResourceFunction["ComplexBubblePlot"][f,{z,zmin,zmax}]

generates a plot of f as an array of disks scaled by Abs[f], over the complex rectangle with corners zmin and zmax.

Details and Options

In a complex bubble plot, each disk has its center at {Re[f[z]],Im[f[z]]}, with the radius a scaling of Abs[f[z]], and colored by Arg[f[z]].
ResourceFunction["ComplexBubblePlot"][f,{z,n}] is equivalent to ResourceFunction["ComplexBubblePlot"][f,{z,-n-n I,n+n I}].
ResourceFunction["ComplexBubblePlot"] treats the variable z as local, effectively using Block.
ResourceFunction["ComplexBubblePlot"] has attribute HoldAll and evaluates f only after assigning specific numerical values to z. In some cases, it may be more efficient to use Evaluate to evaluate f symbolically first.
ResourceFunction["ComplexBubblePlot"] has the same options as Graphics, with the following additions and changes:
ColorFunctionAutomatichow to apply coloring to disks
ColorFunctionScalingTruewhether to scale arguments to ColorFunction
FrameAutomaticwhether to put a frame around the plot
PlotLegendsNonelegends for color gradients
PlotPointsAutomaticthe number of disks in each direction
PlotRangeAutomaticrange of values to include
PlotRangeClippingTruewhether to clip at the plot range
WorkingPrecisionMachinePrecisionthe precision used in internal computations
ColorFunction is supplied with a single argument, given by default by the scaled value of Arg[f[z]].

Examples

Basic Examples (2) 

Plot a complex function:

In[1]:=
ResourceFunction["ComplexBubblePlot"][(z^2 + 1)/(
 z^2 - 1), {z, -2 - 2 I, 2 + 2 I}]
Out[1]=

Include a legend showing how the colors vary from -π to π:

In[2]:=
ResourceFunction["ComplexBubblePlot"][(z^2 + 1)/(
 z^2 - 1), {z, -2 - 2 I, 2 + 2 I}, PlotLegends -> Automatic]
Out[2]=

Scope (3) 

The identity function:

In[3]:=
ResourceFunction["ComplexBubblePlot"][z, {z, -1 - I, 1 + I}]
Out[3]=

Visualize various Power functions:

In[4]:=
Table[ResourceFunction["ComplexBubblePlot"][z^a, {z, -1 - I, 1 + I}, PlotLabel -> ToString[z^a, TraditionalForm]], {a, {-1, 1/2, 2, 3}}] // Partition[#, 2] & // GraphicsGrid
Out[4]=

Visualize a function with an essential singularity:

In[5]:=
ResourceFunction["ComplexBubblePlot"][
 Exp[-1/(8 z^2)], {z, -1 - I, 1 + I}]
Out[5]=

Options (5) 

ColorFunction (1) 

Use a different color function:

In[6]:=
ResourceFunction["ComplexBubblePlot"][Sin[z], {z, -1 - I, 1 + I}, ColorFunction -> (ColorData["M10DefaultDensityGradient", 1 - Abs[2 Mod[#, 1] - 1]] &)]
Out[6]=

ColorFunctionScaling (1) 

Arg[f] is scaled by default. Use ColorFunctionScaling to change it:

In[7]:=
ResourceFunction["ComplexBubblePlot"][Sin[z], {z, -1 - I, 1 + I}, ColorFunction -> Hue, ColorFunctionScaling -> False, PlotLegends -> Automatic]
Out[7]=

PlotLegends (1) 

The Automatic legend shows the association between color and phase:

In[8]:=
ResourceFunction["ComplexBubblePlot"][Sin[z], {z, -1 - I, 1 + I}, PlotLegends -> Automatic]
Out[8]=

PlotPoints (1) 

Use more disks:

In[9]:=
ResourceFunction["ComplexBubblePlot"][Sin[z], {z, -1 - I, 1 + I}, PlotPoints -> 35]
Out[9]=

WorkingPrecision (1) 

Evaluate functions using arbitrary-precision arithmetic:

In[10]:=
ResourceFunction["ComplexBubblePlot"][
 JacobiSD[z EllipticK[1/2], 1/2], {z, -1 - I, 1 + I}, WorkingPrecision -> 25]
Out[10]=

Neat Examples (1) 

Visualize the function -ⅈza with varying a:

In[11]:=
Manipulate[
 ResourceFunction["ComplexBubblePlot"][-I z^a, {z, 1}, ColorFunction -> (ColorData["M10DefaultDensityGradient", 1 - Abs[2 Mod[#, 1] - 1]] &)], {{a, 1}, 0.1, 4, 0.1}, SaveDefinitions -> True]
Out[11]=

Version History

  • 1.0.0 – 20 January 2021

Related Resources

License Information