4
$\begingroup$

I created a list with coefficients to be used in various Sin functions

Map[(#*Pi/5)&,Subdivide[3.5,15,4]]

{2.19911,4.00553,5.81195,7.61836,9.42478}

It can be observed that the values ​​of the list above were inserted manually in the function below:

Plot[{50 Sin[2.19911 x], 50 Sin[4.00553 x], 50 Sin[5.81195 x],50 Sin[7.61836 x], 50 Sin[9.42478 x]}, {x, 0, 10},
 AxesLabel -> {"Time [Second]", "Angle [Degree]"},
 PlotLabel -> "Angle x Time",
 ImageSize -> Large]

enter image description here

I tried to insert these coefficients using Map function. The result is correct, but the colors did not vary.

What should I call in the function for the colors to be different?

Show[Plot[{50 Sin[# x]}, {x, 0, 10}] & /@ Map[(#*Pi/5) &, Subdivide[3.5, 15, 4]],
 AxesLabel -> {"Time [Second]", "Angle [Degree]"},
 PlotLabel -> "Angle x Time",
 ImageSize -> Large]

enter image description here

$\endgroup$

closed as off-topic by Bob Hanlon, MarcoB, m_goldberg, corey979, C. E. Dec 5 '16 at 23:30

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." – Bob Hanlon, MarcoB, m_goldberg, corey979, C. E.
If this question can be reworded to fit the rules in the help center, please edit the question.

7
$\begingroup$
Plot[Evaluate[{50 Sin[# x]} & /@ Map[(#*Pi/5) &, Subdivide[3.5, 15,4]]], {x, 0, 10},
     AxesLabel -> {"Time [Second]", "Angle [Degree]"}, 
     PlotLabel -> "Angle x Time", ImageSize -> Large]

Mathematica graphics

Alternatively, if you have to use Show, you can get the same picture by Styleing each function with a different color:

i=1;
Show[Plot[Style[50 Sin[# x], ColorData[97, "ColorList"][[i++]]], {x, 0, 10}   ] & /@ 
 Map[(#*Pi/5) &, Subdivide[3.5, 15, 4]],
 AxesLabel -> {"Time [Second]", "Angle [Degree]"},
 PlotLabel -> "Angle x Time",
 ImageSize -> Large]
$\endgroup$
8
$\begingroup$

You can exploit the fact that Times, Divide, and Sin are all Listable

Attributes /@ {Times, Divide, Sin}

(*  {{Flat, Listable, NumericFunction, OneIdentity, Orderless, 
  Protected}, {Listable, NumericFunction, Protected}, {Listable, 
  NumericFunction, Protected}}  *)

The Plot then simplifies to

Plot[Evaluate[50 Sin[Subdivide[3.5, 15, 4] Pi/5 x]], {x, 0, 10}, 
 AxesLabel -> {"Time [Second]", "Angle [Degree]"}, 
 PlotLabel -> "Angle x Time", ImageSize -> Large]
$\endgroup$

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