Discussion:
Setting GridLines style for major and minor grid lines
(too old to reply)
dg
2009-06-07 09:01:20 UTC
Permalink
I am drawing a log plot. Because it spans many decades, the grid lines
look horrible in the default setting (they completely overwhelm the
plot). What I want is to only draw the grid lines for the major grid
(for the y axis). I was looking at a way to specify the style of the
gridlines separately for major and minor grid WITHOUT having to
generate all the gridline locations myself. Unfortunately is seems
that in Mathematica 7 GridLinesStyle->{xstyle,ystyle} is the only available
option. It would be SOOOO MUCH BETTER if Mathematica would have:

GridLinesStyle->{{xMajorStyle,xMinorStyle},{yMajorStyle,yMinorStyle}}

Any other easy way to achieve this?


I find that Mathematica still has many irritating limitations with plots.
This is only one I have run into.

TIA
David Park
2009-06-08 05:46:18 UTC
Permalink
I don't know if having two different styles for major and minor grid lines
is a good idea because it will tend to confuse the viewer. Better is to have
fewer grid lines and to make them as light as possible, what Edward Tufte
calls "the minimum effective difference".

Here is a LogLog example from GridLines help where, just for illustration, I
use a full set of grid lines vertically, but a restricted set horizontally.

LogLogPlot[1/x, {x, 1, 10000},
Frame -> True,
GridLines -> {Table[10^n, {n, 0, 4}], Automatic},
GridLinesStyle -> GrayLevel[.85]]


The Presentations package has a CustomGridLines (and also a CustomTicks)
command and a different paradigm that makes it easier to construct custom
graphics with elements from different plot types.


David Park
***@comcast.net
http://home.comcast.net/~djmpark/


From: dg [mailto:***@gmail.com]


I am drawing a log plot. Because it spans many decades, the grid lines
look horrible in the default setting (they completely overwhelm the
plot). What I want is to only draw the grid lines for the major grid
(for the y axis). I was looking at a way to specify the style of the
gridlines separately for major and minor grid WITHOUT having to
generate all the gridline locations myself. Unfortunately is seems
that in Mathematica 7 GridLinesStyle->{xstyle,ystyle} is the only available
option. It would be SOOOO MUCH BETTER if Mathematica would have:

GridLinesStyle->{{xMajorStyle,xMinorStyle},{yMajorStyle,yMinorStyle}}

Any other easy way to achieve this?


I find that Mathematica still has many irritating limitations with plots.
This is only one I have run into.

TIA
Sjoerd C. de Vries
2009-06-08 05:46:29 UTC
Permalink
To draw only the major y-grid lines this simple option works great:

LogLogPlot[x, {x, 1, 10^6}, GridLines -> {None, 10^Range[10]}]

Indeed, I don't think Mathematica does have a major/minor grid
specification, but it's really, really easy to generate yourself (plus
this mechanism gives you much more flexibility):

LogLogPlot[x, {x, 1, 10^6},
GridLines -> {None,
Flatten[Table[{i 10^j,
If[i == 1, GrayLevel[0], GrayLevel[0.9]]}, {j, 0, 6}, {i, 9}],
1]}]

Cheers -- Sjoerd
Post by dg
I am drawing a log plot. Because it spans many decades, the grid lines
look horrible in the default setting (they completely overwhelm the
plot). What I want is to only draw the grid lines for the major grid
(for the y axis). I was looking at a way to specify the style of the
gridlines separately for major and minor grid WITHOUT having to
generate all the gridline locations myself. Unfortunately is seems
that in Mathematica 7 GridLinesStyle->{xstyle,ystyle} is the only availab=
le
Post by dg
GridLinesStyle->{{xMajorStyle,xMinorStyle},{yMajorStyle,yMinorStyle}}
Any other easy way to achieve this?
I find that Mathematica still has many irritating limitations with plots.
This is only one I have run into.
TIA
dg
2009-06-09 07:51:35 UTC
Permalink
Sjoerd,
thank you. Your reply is very useful. I didn't realize that I can
specify gridlines that are outside the plotting area with no ill
effects.

So for example I could use:

GridLines->{Automatic,10^Range[-20,20,1]}

and that will cover pretty much all the log plots I am drawing.

Loading...