1
$\begingroup$

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

$\endgroup$
4
$\begingroup$
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

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

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.