I'm plotting the spherical harmonics on $\phi\in(-\pi,+\pi)$ and $x=\cos\theta\in(-1,+1)$,
Timing@With[{lMax = 4},
GraphicsGrid[Table[
ArrayPad[
Table[ContourPlot[
Re@SphericalHarmonicY[l, m,
ArcCos[x], \[Phi]], {\[Phi], -\[Pi], \[Pi]}, {x, -1, 1},
AspectRatio -> 2/(2 \[Pi])], {m, -l, l}], lMax - l, Graphics[]],
{l, 0, lMax}]
, ImageSize -> 1600]
]
which produces a 5 row triangle of plots (rows are l
, columns are m=-l...+l
. It takes about 15 seconds (which, honestly, seems long, but pales in comparison to ComplexPlot).
In constrast, using ComplexPlot
Timing@With[{lMax = 4},
GraphicsGrid[Table[
ArrayPad[
Table[ComplexPlot[
SphericalHarmonicY[l, m, ArcCos[Im@\[Phi]x],
Re@\[Phi]x], {\[Phi]x, -\[Pi] - I, \[Pi] + I},
AspectRatio -> 2/(2 \[Pi]),
ColorFunction -> "CyclicLogAbsArg"], {m, -l, l}], lMax - l,
Graphics[]],
{l, 0, lMax}]
, ImageSize -> 1600]
]
to produce a similar figure takes substantially longer (1201 seconds). What gives?
A Smaller Example
Consider, for example, just $l=4$, $m=1$. Then, with AbsoluteTiming,
(* ContourPlot Real part *)
AbsoluteTiming@
ContourPlot[
Re@SphericalHarmonicY[4, 1,
ArcCos[x], \[Phi]], {\[Phi], -\[Pi], \[Pi]}, {x, -1, 1},
AspectRatio -> 2/(2 \[Pi])]
(* ContourPlot Imaginary part *)
AbsoluteTiming@
ContourPlot[
Im@SphericalHarmonicY[4, 1,
ArcCos[x], \[Phi]], {\[Phi], -\[Pi], \[Pi]}, {x, -1, 1},
AspectRatio -> 2/(2 \[Pi])]
(* Complex Plot *)
AbsoluteTiming@
ComplexPlot[
SphericalHarmonicY[4, 1, ArcCos[Im@\[Phi]x],
Re@\[Phi]x], {\[Phi]x, -\[Pi] - I, \[Pi] + I},
ColorFunction -> "CyclicLogAbsArg", AspectRatio -> 2/(2 \[Pi])]
These take, 0.84, 0.78, and 127.5 seconds, respectively.
ComplexPlot
that runs slow that we can try? I'm not very eager to run yourTable
command if it takes 1201 seconds. Try for a minimal working example. Also, useAbsoluteTiming
instead ofTiming
. $\endgroup$ComplexPlot
only took23.6849
seconds $\endgroup$$Version == "12.1.1 for Mac OS x86 (64-bit) (June 19, 2020)"
. $\endgroup$