0
$\begingroup$

This question already has an answer here:

Here's a plot of some lines with different styles of filling and one gridline displayed:

LogLogPlot[{10^1 x^(-4/5), 10^15 x^(-4/5), 10^30 x^(-4/5)}, {x, 1, 
  10^40}, PlotRange -> {{0, 10^20}, Automatic}, 
 Filling -> {1 -> Axis, 2 -> {1}, 3 -> {2}, 3 -> Top}, 
 GridLines -> {{10^10}, None}]

but if I want to specify different fill colors, I get a gridline that is covered by the fill instead of the standard behavior:

LogLogPlot[{10^1 x^(-4/5), 10^15 x^(-4/5), 10^30 x^(-4/5)}, {x, 1, 
  10^40}, PlotRange -> {{0, 10^20}, Automatic}, 
 Filling -> {1 -> {Axis, LightOrange}, 2 -> {{1}, LightBlue}, 
   3 -> {{2}, LightGreen}, 3 -> {Top, LightRed}}, 
 GridLines -> {{10^10}, None}]

enter image description here

I've been reading through the docs on Filling and FillingStyle but they don't seem to cover this use case.

How can I specify multiple colors, fills, and gridlines, and show the gridlines normally on top of the solid fill colors?

$\endgroup$

marked as duplicate by J. M. will be back soon Jul 28 '15 at 12:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Use the option Method -> {"GridLinesInFront" -> True}? $\endgroup$ – kglr Apr 5 '15 at 17:34
  • $\begingroup$ Possibly related 28025. $\endgroup$ – dionys Apr 5 '15 at 17:43
  • $\begingroup$ @kguler Thanks for the heads up on the undocumented option. Unfortunately, I get error message LogLogPlot::optx (unknown option) when I try to set GridLinesInFront->True. $\endgroup$ – dionys Apr 5 '15 at 17:48
  • $\begingroup$ you need to use it as Method -> {"GridLinesInFront" -> True}, i.e., as the value of the option Method. $\endgroup$ – kglr Apr 5 '15 at 17:55
2
$\begingroup$

This question has been answered elsewere.

As @kglr helpfully pointed out in the comments, the undocumented option:

Method -> {"GridLinesInFront" -> True}

will cause the gridlines to display over the fill and styled curves:

LogLogPlot[{10^1 x^(-4/5), 10^15 x^(-4/5), 10^30 x^(-4/5)}, {x, 1, 
  10^40}, PlotRange -> {{0, 10^20}, Automatic}, 
 Filling -> {1 -> {Axis, LightOrange}, 2 -> {{1}, LightBlue}, 
   3 -> {{2}, LightGreen}, 3 -> {Top, LightRed}}, 
 GridLines -> {{10^10}, None}, Method -> {"GridLinesInFront" -> True}]

enter image description here

$\endgroup$

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