# Plotting several functions, each one with different properties using Table

I have these four different functions in the same plane:

    Plot[Evaluate[Table[Sqrt[2/Pi] Sin[(n Pi x)/Pi], {n, 4}]], {x, 0, Pi},
AxesLabel -> {"x", "\[CapitalPhi]"},
PlotLegend -> {"n = 1", "n = 2", "n = 3", "n = 4"},
PlotStyle -> {{Thick, Blue}, {Thick, Dashed, Red},
{Thick, DotDashed, Orange}, {Thick, Dashing[Large], Green}}]


Now I want to plot those four functions, each one in a different plane, preserving their unique properties. I tried something like:

    Table[Plot[Sqrt[2/Pi] Sin[(n Pi x)/Pi], {x, 0, Pi},
AxesLabel -> {"x", "\[CapitalPhi]"}], {n, 4},
PlotLegend -> {"n = 1", "n = 2", "n = 3", "n = 4"},
PlotStyle -> {{Thick, Blue}, {Thick, Dashed, Red},
{Thick, DotDashed, Orange}, {Thick, Dashing[Large], Green}}]


but Mathematica tells me that it does not have the correct form of an iterator. How can I solve this?

Try this:

lst = {Blue, {Dashed, Red}, {Orange, DotDashed}, {Green,
Dashing[Large]}};
Grid[{Table[
Plot[Sqrt[2/\[Pi]] Sin[(n \[Pi] x)/\[Pi]], {x, 0, \[Pi]},
AxesLabel -> {"x", "\[CapitalPhi]"}, ImageSize -> 250,
PlotLabel -> Row[{"n=", n}], PlotStyle -> {Thick, lst[[n]]}], {n,
4}]}] Have fun!

• WOWWW!!! Thanks A LOT for this, bro! If you could explain me how does that "lst" work, you'll be my god from now. Please! Nov 17, 2021 at 0:12
• I've already figured out. You are defining a set called lst. The set can be defined as we wish. :) Nov 17, 2021 at 11:57
• I defined an auxiliary list: lst = {Blue, {Orange, DotDashed}, {Green, Dashing[Large]}};. Its first element is lst[]. It is equal to Blue. The second element, lst[] is {Dashed, Red} and so on. Therefore, PlotStyle -> {Thick, lst[[n]]} for each element of the Table gives the desired style option. Nov 17, 2021 at 13:38
• Thank you. Have a great day! Nov 17, 2021 at 14:10

Try this:

Table[Plot[Sqrt[2/Pi] Sin[(n Pi x)/Pi], {x, 0, Pi},
AxesLabel -> {"x", "\[CapitalPhi]"},
PlotLegends -> {"n = 1", "n = 2", "n = 3", "n = 4"},
PlotStyle -> {{Thick, Blue}, {Thick, Dashed, Red}, {Thick,
DotDashed, Orange}, {Thick, Dashing[Large], Green}}], {n, 4}]

• I've Mathematica ver.8.0, so PlotLegends is not supported :( Thanks anyway, bro. Nov 16, 2021 at 23:59