FAQ
overflow

Great Answers to
Questions About Everything

QUESTION

I need to create graphs with light gray axes and black lines. All of my plots display behind the axes. How can I make the plots display over the axes?

Plot[2 x - 2, {x, -10, 10}, PlotRange -> {{-10, 10}, {-10, 10}},    
    PlotStyle -> Directive[Black, AbsoluteThickness[2]], ImageSize -> 300, 
    AxesStyle -> Directive[RGBColor[.8, .8, .8], AbsoluteThickness[2]], AspectRatio -> 1]

{ asked by lvames }

ANSWER

The cure is undocumented, unfortunately. Try adding Method -> {"AxesInFront" -> False}, like so:

Plot[2 x - 2, {x, -10, 10}, PlotRange -> {{-10, 10}, {-10, 10}}, 
     PlotStyle -> Directive[Black, AbsoluteThickness[2]], ImageSize -> 300, 
     AxesStyle -> Directive[RGBColor[.8, .8, .8], AbsoluteThickness[2]], 
     AspectRatio -> 1, Method -> {"AxesInFront" -> False}]

plot with axes in front

{ answered by J. M. }
Tweet