# How to get grid lines at all (log) tick marks in Version 10?

In Version 7 using GridLines -> Automatic (or All) would put a grid line at every log-spaced tick mark:

LogPlot[x^x, {x, 1, 5},
GridLinesStyle -> LightGray,
GridLines -> Automatic,
Frame -> True]


In Version 10 this is no longer the case:

What is the simplest way to recover the old behavior?

-
Nice plot from Version 7, why did WRI remove this features from LogPlot? But trying something I think I found a problem. Posting question now :) –  Nasser Jul 12 '14 at 9:04
@Nasser I suppose they consider the new form more clean, but I rely on that feature to clearly see the values on log plots. If there is no simple method I'll have to code a GridLines function to do it. –  Mr.Wizard Jul 12 '14 at 9:08
I was trying to do that, using GridLines->function but I think there is a bug, please see question I just asked on this. –  Nasser Jul 12 '14 at 9:10
Are we tagging the howto in v10 questions with version-10 or is that going to get cumbersome quickly? –  bobthechemist Jul 12 '14 at 15:04
@bobthechemist Please untag them when you see them... I don't know who started this trend, but that is not how we were doing things before. A exceptions can be made when it has been confirmed as a bug by the community –  The Toad Jul 12 '14 at 15:11

Now that specifying a GridLines function has been repaired we can use this:

logticks[a_, b_] := First /@ ChartingScaledTicks[{Log, Exp}][a, b] // Exp;


Note that a slightly different option value is needed for each plot type. One could make these options the default using SetOptions, but if you prefer to keep the existing default and simplify application of this style I propose a custom PlotTheme:

MapThread[
ThemesAddThemeRules["LogGrid", #, GridLines -> #2, Frame -> True] &,
{
{LogPlot | ListLogPlot, LogLinearPlot | ListLogLinearPlot, LogLogPlot | ListLogLogPlot},
{{Automatic, logticks}, {logticks, Automatic}, logticks}
}
];


Now you can enable this style for any log plot using PlotTheme -> "LogGrid":

LogPlot[x^x, {x, 1, 5},
GridLinesStyle -> LightGray, PlotTheme -> "LogGrid", Frame -> True]


LogLinearPlot[Log @ x, {x, 1, 500},
GridLinesStyle -> LightGray, PlotTheme -> "LogGrid", Frame -> True]


LogLogPlot[x, {x, 0.1, 15},
GridLinesStyle -> LightGray, PlotTheme -> "LogGrid", Frame -> True]


To provide some additional contrast one might wish to style the major division grid lines differently. Here is an alternate definition for logticks to effect this.

Options[logticks] = {"MajorStyle" -> {}};   (* uniform style by default *)

logticks[a_, b_] :=
Replace[
ChartingScaledTicks[{Log, Exp}][a, b],
{{p_, _Spacer, ___} :>
Exp[p], {p_, ___} :> {Exp@p, OptionValue[logticks, "MajorStyle"]}},
{1}
]


Now set a style:

SetOptions[logticks, "MajorStyle" -> {Thick, Orange, Opacity[0.5]}];


And the result:

LogPlot[x^x, {x, 1, 5},
GridLinesStyle -> LightGray,
PlotTheme -> "LogGrid",
Frame -> True
]


-
LogPlot[x^x, {x, 1, 5}, GridLinesStyle -> LightGray,
GridLines -> {Range[5],
Flatten[Table[n, {n, 1 #, 9 #, 1 #}] & /@ (10^Range[0, 4])]},
Frame -> True]


-
The problem is that hard-coded grid lines have to be adjusted manually for every individual plot. –  Jens Jul 12 '14 at 18:50
Of course I agree. I am in fact very unhappy with the various Log???Plot functions. In my opinion there should be a single Plot (and a single Plot3D) function, which is supplemented by ScalingFunction->{"Lin", "Log"} or something very similar. –  Ernst Stelzer Jul 12 '14 at 19:07
That would indeed be very nice. There are so many new finance related charting functions etc., but no progress in actual scientific plotting. –  Jens Jul 12 '14 at 19:29
@ErnstStelzer Apparently we have that now, or the easy ability to implement it, as ParametricPlot supports ScalingFunctions (unofficially). See Simon Woods' answer: (55882) –  Mr.Wizard Jul 27 '14 at 17:10
@Mr.Wizard Thank you very much for the hint. It actually works inside Plot. I managed to crash the kernel with some combinations but "Reverse"` worked too. –  Ernst Stelzer Jul 29 '14 at 13:30