Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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]

share|improve this question
1  
This post by Verbeia might also be of interest. –  TomD Jun 13 '13 at 9:45
add comment

3 Answers 3

I found this useful, though a little ugly.

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

But you cannot directly save the image, you can select the cell and save selection as image.

enter image description here

Reverse the list in Overlay will get the result where black line behind the axes.

share|improve this answer
add comment

There can be another solution, FullGraphics can convert the axes to graphics primitives, then you can manipulate the order of layers by hand.

FullGraphics[
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]] /. Graphics[x_] :> Graphics[Reverse[x]]

Comment from rcollyer:

FullGraphics is spotty, so take care in its use.

share|improve this answer
    
AxisInFront is simple and works well. I'll give that a good testing for my project. Good to know there is another option, especially for my own knowledge. Thank you! –  lvames Jun 13 '13 at 10:40
    
@lvames Glad I can help. –  mm.Jang Jun 13 '13 at 10:58
7  
@lvames FullGraphics is spotty, so take care in its use. –  rcollyer Jun 13 '13 at 16:20
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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