0
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – m_goldberg
    Feb 12, 2018 at 23:28

1 Answer 1

3
$\begingroup$
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 π}]
$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – violeta
    Feb 13, 2018 at 0:03
  • $\begingroup$ 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]]. $\endgroup$ Feb 13, 2018 at 0:58
  • $\begingroup$ @DavidG.Stork Function[{y}, Hue[y/10] is the same as Function[x, Hue[x/10], you need Function[{x, y}, Hue[y/10]. $\endgroup$
    – Kuba
    Feb 13, 2018 at 6:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.