# Visualizing the amplitude and phase of a one-dimensional wave function [closed]

I want to replicate a plot I found on wikipedia:

https://en.wikipedia.org/wiki/File:QHO-coherentstate3-animation-color.gif

Which is a visualization of a function from the real numbers to the complex numbers. I started just trying to plot the absolute value of the function and then color it by its argument using Plot and ColorFunction by I couldn't quite figure out how ColorFunction works. Any help doing that, and then maybe going forward in replicating the whole thing by filling the area under the curve with the color of each point?

• What article in Wikipedia does the animation you link to come from? I don't think the animation alone provides sufficient information to answer your question. Feb 12, 2018 at 23:28

Animate[
Plot[
PDF[NormalDistribution[Sin[t], 1], x],
{x, -5, 5},
ColorFunction -> Function[x, Hue[Abs[Sin[t/2 + x]]]],
Filling -> Axis],
{t, 0, 4 π}]

• oh, thank you, i get it! so the color function can be a function that takes as input the same input of the function i'm plotting, right? Feb 13, 2018 at 0:03
• Yes... that is right. You can define the color other ways too (e.g., by the function output): Function[{y}, Hue[y/10]. Or by mixtures of variables, Function[{x,y}, Hue[(x+y)/20]]. Feb 13, 2018 at 0:58
• @DavidG.Stork Function[{y}, Hue[y/10] is the same as Function[x, Hue[x/10], you need Function[{x, y}, Hue[y/10].
– Kuba
Feb 13, 2018 at 6:45