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$

closed as off-topic by m_goldberg, anderstood, MarcoB, Coolwater, José Antonio Díaz Navas Feb 13 '18 at 12:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – m_goldberg, anderstood, MarcoB, Coolwater, José Antonio Díaz Navas
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\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 '18 at 23:28
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$
  • $\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 '18 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$ – David G. Stork Feb 13 '18 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 '18 at 6:45

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