2

If I do a plot and want both the horizontal axis and a frame I can do this:

Plot[Sin[2 π 10 t], {t, 0, 1},
 PlotStyle -> {Black, Thickness[0.01]},
 Frame -> True, Axes -> True,
 AxesStyle -> {{Orange, Thickness[0.01]}, {Orange, Thickness[0.01]}}]

Mathematica graphics

The axis is in front of the plotted line. However, because of this useful post we can do

Plot[Sin[2 π 10 t], {t, 0, 1},
 PlotStyle -> {Black, Thickness[0.01]},
 Frame -> True, Axes -> True,
 AxesStyle -> {{Orange, Thickness[0.01]}, {Orange, Thickness[0.01]}},
 Method -> {"AxesInFront" -> False}]

Mathematica graphics

and the axes is behind the line. Now I wish to do this with ListLinePlot but then I get

data = Table[{t, Sin[2 π 10 t]}, {t, 0, 1, 0.005}];
ListLinePlot[data,
 PlotStyle -> {Black, Thickness[0.01]},
 Frame -> True, Axes -> True,
 AxesStyle -> {{Orange, Thickness[0.01]}, {Orange, Thickness[0.01]}},
 FrameStyle -> {Black, Thickness[0.001]},
 Method -> {"AxesInFront" -> False}]

Mathematica graphics

and the axis is back in front of the line. How to I get the axes behind the lines for a ListLinePlot? Thanks

Hugh
  • 16,387
  • 3
  • 31
  • 83

1 Answers1

6
data = Table[{t, Sin[2 π 10 t]}, {t, 0, 1, 0.005}];

Use Show

Show[
 ListLinePlot[data,
  PlotStyle -> {Black, Thickness[0.01]}],
 Frame -> True,
 Axes -> True,
 AxesStyle -> {{Orange, Thickness[0.01]},
   {Orange, Thickness[0.01]}},
 FrameStyle -> {Black, Thickness[0.001]},
 Method -> {"AxesInFront" -> False}]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • 1
    Excellent. How do you know these things? – Hugh Apr 16 '19 at 18:05
  • @Hugh - your question shows that Method -> {"AxesInFront" -> False} works with some graphics functions. Experimentation then reveals that the Method has been implemented with Show. – Bob Hanlon Apr 16 '19 at 19:27