How would one have the trajectory in a parametric plot go from a higher to lower opacity? Suppose the following code for example:

Manipulate[ParametricPlot[{Cos[f1 t], Sin[f1 t]},
  {t, 0, 4 π}, PlotRange -> 2, PerformanceGoal -> "Quality"],
 {{f1, -0.3, "Frequency 1"}, -2 π, 2 π}]

This would show a circle. The goal is to show the line as a 'faded track' to represent the time progression, as opposed to a boring ol' solid line. I tried adding Opacity[t/(4 π)] to the plot options, which unsurprisingly failed.

up vote 3 down vote accepted
Manipulate[ParametricPlot[{Cos[f1 t], Sin[f1 t]}, {t, 0, 4 Pi}, 
  PlotStyle -> Thickness[.01], 
  ColorFunction -> (Opacity[1 - #3/ 4 / Pi, Red] &), 
  ColorFunctionScaling -> False, PlotRange -> 2, 
  PerformanceGoal -> "Quality"], 
 {{f1, -0.3, "Frequency 1"}, -2 Pi, 2 Pi}]

enter image description here

Or use

 ColorFunction -> (Opacity[#3/ 4/Pi, Red] &)

to get

enter image description here

  • What does Opacity[1 - #3/ 4 / Pi, Red] & mean? I don't understand the argument nor the ampersand – Captain Morgan Aug 10 at 21:23
  • 1
    @CaptainMorgan See Function and ColorFunction in the documentation. – Mr.Wizard Aug 10 at 21:31
  • 1
    @CaptainMorgan, for ParametricPlot that produces a curve (two argument form: ParametricPlot[{$f_x$, $f_y$}, {$t$ ,$t_{min} , t_{max}$}] ) the settings for option ColorFunction can be functions that take three arguments (x, y and t). The function Opacity[1 - #3/ 4 / Pi, Red] & is the same as Function[{x,y, t}, Opacity[t/4/Pi, Red]]. – kglr Aug 10 at 21:33
  • @kglr, so the #3 is effectively t. Where is this referenced from? Would #2 be y such that the trajectory would instead change opacity based on height? Also, I see that in the documentation that & points to the function argument (I think?) I don't understand its role though here. Nothing follows it. – Captain Morgan Aug 10 at 21:56
  • @CaptainMorgan, you are right, #n refers to the $n$th argument. See Slot (#) in the documentation. you can define a function in a number of ways: For example, f1 = Function[{x, y, z}, x + 2 y + 3 z];f2 = (# + 2 #2 + 3 #3) &; f3[x_, y_, z_] := x + 2 y + 3 z are alternative ways of defining the same function, and f1[a, b, c],f2[a, b, c] and f3[a, b, c] all give a + 2 b + 3 c. – kglr Aug 10 at 22:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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