Plotting complex functions

Hi all,

I wanted to plot complex valued functions with real support:

  f : R -> C

The plot should show the absulote value abs(f)^2 and the phase angle(f).
The demand for such a plot type originates from quantum mechanics
where I want to plot |phi> and/or <phi|phi> in this way showing
the phase of the wave function.

For this task I wrote a little script and it works quite well.
But I have a question regarding the color coding of the phase.

Is there a better way to provide the rgb_colors to the line collection?

Any hints to make the script more efficient would help.
I need to run it on hundreds of frames to produce animations.

BTW: You can add this to your gallery page if you want.
Maybe it's helpful to other people.

-- Raoul (1.94 KB)