2
$\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
    $\begingroup$ Try modifying your LineLegend[]: LineLegend[directives, strings, Background -> White, opts] $\endgroup$ – J. M. will be back soon Mar 30 '18 at 13:37
2
$\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$

Your Answer

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

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