0
$\begingroup$
    Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, PlotStyle -> {Red, Blue}, 
 PlotLegends -> Placed[{"fx", "fy"}, Above]]    

enter image description here

How can we add another label to the left like this:

enter image description here

$\endgroup$
5
  • $\begingroup$ PlotLegends -> {Placed[ ..], Placed[ ..]} $\endgroup$
    – Syed
    Sep 22, 2022 at 15:18
  • $\begingroup$ @Syed, may u please post an answer? PlotLegends -> {Placed[{"fx", "fy"}, Above], Placed[{"x", "y"}, Above]} did not work $\endgroup$
    – MMA13
    Sep 22, 2022 at 15:29
  • $\begingroup$ not working too $\endgroup$
    – MMA13
    Sep 22, 2022 at 15:34
  • $\begingroup$ I see this on v12.2.0Win7-x64. $\endgroup$
    – Syed
    Sep 22, 2022 at 15:36
  • $\begingroup$ that is not what I would like to see. kindly see 2nd [fig ](i.sstatic.net/eGYeP.png) in the question green labels x and y $\endgroup$
    – MMA13
    Sep 22, 2022 at 15:41

1 Answer 1

2
$\begingroup$

Using the answer from 187933 by@kglr:

strx = StringJoin[
  ToString[Style[x, Darker@Green, 14, FontFamily -> "Arial"], 
   StandardForm]
  , ToString[Style[" \[LongDash]", 14, Red, FontFamily -> "Arial"], 
   StandardForm]
  , ToString[Style[" fx", 14, Black, FontFamily -> "Arial"], 
   StandardForm]
  ];
stry = StringJoin[
  ToString[Style[y, Darker@Green, 14, FontFamily -> "Arial"], 
   StandardForm]
  , ToString[Style[" \[LongDash]", 14, Blue, FontFamily -> "Arial"], 
   StandardForm]
  , ToString[Style[" fy", 14, Black, FontFamily -> "Arial"], 
   StandardForm]
  ];

Plot[{
  Sin[x], Cos[x]
  }
 , {x, 0, 2 \[Pi]}
 , PlotStyle -> {Red, Blue}
 , PlotLegends -> {
   Placed[{"fx", "fy"}, Above]
   , Placed[PointLegend[{White, White}, {strx, stry}], Left]
   }
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ now if I change the PlotStyle -> {Black, Blue} we need to change strx and stry $\endgroup$
    – MMA13
    Sep 22, 2022 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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