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.


closed as off-topic by m_goldberg, corey979, march, Feyre, MarcoB Jan 12 '17 at 5:05

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

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, corey979, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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.