4
$\begingroup$

When I plot a function with legend and axes, the legend gets placed behind the axes (see example below)



I would like to have the legend sitting in front of everything. Is there a parameter that controls this? If not, what is the easiest way to accomplish this. I must emphasize that I'm generating many plots, and I would like to avoid long manual adjustments.

Code used to generate figure:

Plot[{Sin[a],Sin[a-2/3Pi],Sin[a+2/3Pi]},{a,0,4Pi}, PlotLegends->Placed[LineLegend[{"ia","ib","ic"}, 
LegendFunction->(Framed[#,BaseStyle->FontSize->8, Background->White, RoundingRadius->2, FrameMargins->None,
FrameStyle->Directive[Thin,Black]]&), Spacings->0.0, LegendMarkerSize->10],{{.99,.99},{1,1}}], 
ImageSize->180, AspectRatio->1/2]

"11.2.0 for Microsoft Windows (64-bit)"

$\endgroup$
4
  • 2
    $\begingroup$ Do you get what you need if you add the option Method -> {"AxesInFront" -> False} to Plot? $\endgroup$
    – kglr
    Commented Aug 6, 2018 at 23:48
  • 1
    $\begingroup$ @kglr that works on 11.3 on macos. $\endgroup$
    – rcollyer
    Commented Aug 7, 2018 at 0:01
  • $\begingroup$ I did not try that method. It works. Thank you. $\endgroup$
    – ercegovac
    Commented Aug 7, 2018 at 8:26
  • $\begingroup$ Is there a place where all 'Plot' methods are documented? I found this answer from @Michael E2, but it does not contain this particular method, which leads me to conclude that there might be some other methods not listed there. $\endgroup$
    – ercegovac
    Commented Aug 7, 2018 at 9:07

1 Answer 1

5
$\begingroup$

Using the option Method -> {"AxesInFront" -> False} in Plot gives (in version 9 / windows 10 - 64 bit):

enter image description here

$\endgroup$

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.