0
$\begingroup$

I have a few plots of different type. plot1 has gridlines and the rest do not. I use the option Method -> {"GridLinesInFront" -> True}] when plotting plot1. When I use Show to combine the plots the gridlines fall infront of the crosses as well which is not what I want. How do I force the crosses to appear completely in front of the figure.

I.e. I want to use Show[plot1,plot2,plot3,plot4] with some kind of options that transforms my figure from this:

to this:

where evidently some other (irrelevant) changes have been made.

$\endgroup$
  • $\begingroup$ Many of the style elements of plots are buried in the graphics directives. You can post-process the individual plots, but it's often easier just to recompute the plots with the new styling. You cannot change the styling as shown in the question by only using options passed to Show. Rules like plot /. _AbsoluteThickness -> AbsoluteThickness[1] have to be applied to the graphics and not as options to Show. $\endgroup$ – Michael E2 Oct 28 '14 at 17:55
  • $\begingroup$ Thanks for the response, that's fine, but what I'm really interested in here, is getting the "X" to appear in front of the gridlines. The gridlines belong to one plot and the "X" to another $\endgroup$ – Tom Oct 28 '14 at 18:47
  • $\begingroup$ I see. I was distracted from that due to the many differences between the before and after images. $\endgroup$ – Michael E2 Oct 28 '14 at 18:50
  • 2
    $\begingroup$ Use Epilog: Plot[Sin[x], {x, -1, 1}, GridLines -> {{0}, {0}}, Frame -> True, Axes -> False, GridLinesStyle -> AbsoluteThickness@5, PlotStyle -> Thick, Method -> {"GridLinesInFront" -> True}, Epilog -> {Text[Style[x, 38], {0, 0}]}] $\endgroup$ – Kuba Oct 28 '14 at 18:51
  • $\begingroup$ Yes sorry @MichaelE2 it's a pretty poor question, I'll neaten it up shortly and answer myself when I figure it all out. Kuba that answered my question thank you $\endgroup$ – Tom Oct 28 '14 at 22:56
3
$\begingroup$

According to documentation Epilog is applied after Axes even with Method->"AxesInFront" (and it seems after GridLines too) so you can use it to set layers as you need:

 Plot[Sin[x], {x, -1, 1},  GridLines -> {{0}, {0}}, Frame -> True,  Axes -> False, 
                      GridLinesStyle -> Directive[Red, AbsoluteThickness@9],
                           PlotStyle -> AbsoluteThickness@9, 
                              Method -> {"GridLinesInFront" -> True}, 
                              Epilog -> {Text[Style["X", 38, Bold], {0, 0}]}, 
                          Background -> LightBlue]

enter image description here

$\endgroup$

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.