1
$\begingroup$

I'm using a plot with a black background and I have a plotlegend

PlotLegends -> 
 Placed[{Transmitted, Reflected, Energy Conservation, 
   "white"}, {{1, .75}, {0.7, 0.5}}]

How can I get the plot legend text colour to be white? It stays as black. I've tried putting a vector

{"white"}

inside the code but it clashes with the placing coordinates. Thanks in advance.

$\endgroup$
0

1 Answer 1

1
$\begingroup$
Plot[{x, 2 x, x^2}, {x, 0, 5}, Background -> Black, 
 PlotLegends -> Placed[Style[#, White] & /@ {Transmitted, Reflected, 
     Energy Conservation}, {{1, .75}, {0.7, 0.5}}]]

enter image description here

or use the third argument of Placed to specify the styling:

PlotLegends -> Placed[{Transmitted, Reflected, Energy Conservation},
    {{1, .75}, {0.7, 0.5}}, 
    Style[#, White] &]

same picture

Alternatively, use the option LabelStyle -> White in Plot:

Plot[{x, 2 x, x^2}, {x, 0, 5}, 
 Background -> Black, 
 LabelStyle -> White,
 PlotLegends -> Placed[{Transmitted, Reflected, Energy Conservation}, 
   {{1, .75}, {0.7, 0.5}}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Perfect thanks. $\endgroup$ Feb 17, 2020 at 11:18

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.