0
$\begingroup$

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

enter image description here

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

$\endgroup$
  • $\begingroup$ It has to be like that PlotLegends -> {"Y1"}]; $\endgroup$ – user66791 Jul 31 at 9:42
  • 1
    $\begingroup$ 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"}] $\endgroup$ – Lukas Lang Jul 31 at 10:54
  • $\begingroup$ 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! $\endgroup$ – Michael E2 Jul 31 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.