# PlotLegend Colors Missing

I want a PlotLegend with the colors of the graphics.

p4 = Plot[y1[t] /. s1, {t, 0, tmax}, PlotRange -> All, PlotStyle -> {{Gray}}, PlotLegends -> "Y1"];


Like here the color Gray, but the plot looks like that

For the other Legends I have used the code

 PlotLegends -> LineLegend[{Gray, Dashed}, {"Y2"}]]


But as you can see in the picture Y2 is not dashed.

So, is there something wrong in the code? Thank you in advance

• It has to be like that PlotLegends -> {"Y1"}]; – user66791 Jul 31 at 9:42
• I don't see how the code you provided is connected to the plots you show - please provide a self-contained, minimal working example with your question, so people can help you more efficiently. To answer what I think your question is: you need to group the styles using Directive, otherwise Dashed is interpreted as belonging to the (nonexistent) second legend entry. This means it should be: PlotLegends -> LineLegend[{Directive[Gray, Dashed]}, {"Y2"}] – Lukas Lang Jul 31 at 10:54
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Jul 31 at 15:13