1
$\begingroup$

To generate a plot of multiple functions, I currently use this syntax:

Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, 
 PlotLegends -> "Expressions"]

This generates a plot of 3 functions as shown below. enter image description here

I would like to fund out if there is a way to instead loop through values of i = 1, 2 and 3 plotting the function y = Sin(ix) to come up with the same result.

$\endgroup$
  • 4
    $\begingroup$ try Plot[Evaluate[Sin[# x] & /@ Range[3]], {x, 0, 2 Pi}, PlotLegends -> "Expressions"]? $\endgroup$ – kglr Jan 11 '17 at 14:52
  • 2
    $\begingroup$ Or Plot[Evaluate@Table[Sin[i x], {i, 1, 3}], {x, 0, 2 Pi}, PlotLegends -> "Expressions"] $\endgroup$ – corey979 Jan 11 '17 at 15:01
  • $\begingroup$ Both of these work. Why does Plot [Table[Sin[i x], {i, 1, 3}], {x, 0, 2 Pi}] provide the plot but not the different colors? $\endgroup$ – user32882 Jan 11 '17 at 15:49
  • $\begingroup$ @user32882 mathematica.stackexchange.com/q/1731/5478 $\endgroup$ – Kuba Jan 11 '17 at 16:31
  • 1
    $\begingroup$ Possible duplicate of Plot draws list of curves in same color when not using Evaluate $\endgroup$ – march Jan 11 '17 at 18:44

Browse other questions tagged or ask your own question.