5
$\begingroup$

i'm trying to set a white background in my framed lagend, soh that it could overlap the curves. Note that in the left corner on the top of the frame there are curves inside the legend. I would like to know how to color this frame in white, so that curves couldn't appear above it. Thanks!

enter image description here

i am using this configuration:

ListLogPlot[{sim[[1]], sim[[2]], sim[[3]], sim[[4]], sim[[5]], 
sim[[6]], sim[[7]], sim[[8]], sim[[9]]}, 
DataRange -> {snrdBMin, snrdBMax}, 
PlotRange -> {{snrdBMin, snrdBMax}, {10^-8, 1}}, Axes -> False, 
Joined -> {True, True, True, True, True, True, True, True}, 
PlotMarkers -> {"\[FilledCircle]", "\[FilledCircle]", 
"\[FilledCircle]", "\[FilledCircle]", "\[FilledCircle]", 
"\[FilledCircle]", "\[FilledCircle]", 
"\[FilledCircle]"},(*BaseStyle\[Rule]{FontSize\[Rule]16},*)
PlotStyle -> {Directive[Red], Directive[Red, Dashed], 
Directive[Blue], Directive[Blue, Dashed], Directive[Darker[Green]],
Directive[Darker[Green], Dashed], Directive[Black], 
Directive[Black, Dashed]}, Frame -> True, 
FrameLabel -> {"SNR", "OP"}, FrameStyle -> Directive[Black, 16], 
AspectRatio -> 0.85,
PlotLegends -> 
Placed[LineLegend[{Directive[Red], Directive[Red, Dashed], 
 Directive[Blue], Directive[Blue, Dashed], 
 Directive[Darker[Green]], Directive[Darker[Green], Dashed], 
 Directive[Black], 
 Directive[Black, Dashed]}, {"LLLLLLLLLLLLLLLLLLLLLLLLL", "OOO", 
 "PPP", "QQQ", "RRR", "SSS", "TTT", "UUU"}, Joined -> True, 
 LegendMarkers -> {"\[FilledCircle]", "\[FilledCircle]", 
  "\[FilledCircle]", "\[FilledCircle]", "\[FilledCircle]", 
  "\[FilledCircle]", "\[FilledCircle]", "\[FilledCircle]"}, 
  LegendFunction -> Framed, LegendMargins -> {{2, 2}, {2, 2}}, 
  LegendMarkerSize -> {20, 20, 20, 20}], {{0.01, 0.01}, {0, 0}}]]
$\endgroup$
1
  • 1
    $\begingroup$ Try modifying your LineLegend[]: LineLegend[directives, strings, Background -> White, opts] $\endgroup$ Mar 30, 2018 at 13:37

1 Answer 1

7
$\begingroup$

If you use (say) Framed to provide the LegendFunction option, for the plot, you can pass the Background -> White option to it, like so:

pts = Through[{Sin, Cos}[Range[0, 2, 0.1]]];
ListPlot[pts, Joined -> True, PlotMarkers -> Automatic,
 PlotLegends -> 
  Placed[LineLegend[{"AAA", "BBB"}, 
    LegendFunction -> (Framed[#, FrameMargins -> 0, 
        Background -> White] & )], {Right, Bottom}],
 Frame -> True
]

plot with legend

$\endgroup$
0

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.