Grid lines

Grid lines and tick marks #


You should at least show two tick marks ore grid lines, but then think carefully about how many more to show.


You might consider tick marks and grid lines to be a relatively small component of data visualizations, and wonder why you need to read such a long article on them. But, if you are in the business of really thinking about how to create effective data visualizations, then you are in the business of “sweating the small stuff.” So, let’s get started!

Why we use tick marks and grid lines #

As discussed in the page on axes, the primary reason that axes exist is to provide a quantitative scale against which to plot data. This purpose is accessed by the software that plots the data, and display of this scale is not a strict requirement. For instance, pie charts often do not show the axes against which the data is plotted.

However, in most data visualizations, this scale is explicitly shown, in the form of axes. Then one needs to provide some information to help people become oriented to this scale. At a minimum, you need to provide numbers for the scale, but it is common to ‘anchor’ these numbers to the line using tick marks or grid lines. If you do not have these ‘anchors,’ then the numbers sort of “float” on the axis.

This is particularly important for the quantitative axes of bar charts, which need to start at a proper reference value (usually 0) to be properly constructed

.

Choose reasonable lengths for the tick mark line #

If you are using tick marks, then you need to consider how to draw them. I, personally, prefer subtle tick marks, and so prefer using short ones. But how short is too short? I take a clue for the text that I am using to label them. If font is set at a size that is easy to read, perhaps I can use a tick mark that is 50% as long. Thus, if I am using 10 point font, I will use major tick marks that are the equivalent of 5 points in size.

When thinking about major tick marks, I usually try to use something that is 33% or 50% as long, usually favoring the former. So, for a 5 point size tick major tick mark, my minor tick marks are often 2 points in size.

There is also the question of line width. It is not uncommon to see cases where the major tick marks are noticeably thicker than the minor ones:

However, I often do not use different widths for my major and minor tick marks, since I think that adds visual clutter—it introduces a new parameter that is not needed. Instead, the difference in lengths—and the fact that the major tick marks are labeled, while the minor ones are not—is sufficient to distinguish the two types of tick marks. Thus, I will often just use the same thickness as the axis line, providing a visual indication that the major and minor tick marks are really part of the axis system.

Use gridlines when you want a much stronger tick mark or want to divide up your plot visually #

Are you worried that people may miss your tick marks? If so, then you might consider using gridlines. Gridlines show the location of tick marks, but extend the length of the tick mark across the plotting area. Thus, the grid lines will overlap with the data—the very place people are looking—and so people are less likely to overlook them.

The fact that gridlines overlap with data, however, suggest that they are competing for attention with your data. Thus, I think the default should always be use to tick marks (keeping the plotting area clutter free) and then ask your self if you really need grid lines.

Of course you can reduce this weight by changing the color to be more grey, instead of black.

But even here, I think that the gridlines are a bit distracting, and so I would just stick with tick marks, unless there is a good reason for gridlines.

One such reason may be for non-linear axes. People can overlook the scale indicators, when they are tick marks, and using gridlines puts this right in their face.

Just accept that, by doing so, you have added some clutter to your plot.

Another place that gridlines can make sense is when you wish to divide up a plot in to regions that make sense. For instance, perhaps you have quadrants in a plot, split up at a particular value. Using gridlines for these can really produce a strong visual representation of them—communicating meaning.

And this is a golden rule for the design of data visualizations: if introducing a visual element helps you communicate your story better, then it was probably a good design idea.

Choose reasonable thicknesses, patterns, and colors for your grid lines #

Unlike tick marks, you cannot really have different lengths of grid lines. The grid lines extend across the entire plotting canvas. Thus, the variables that remain are the same as we have for any line: thickness, patterns, and color. You will see all of these used to distinguish between gridlines. I do not wish to go into depth here, since this is covered well in the page on lines. But we can illustrate a few ideas.

Thickness #

In using thickness, I often set the major grid line at a thickness equal to that of the axes, and then the minor grid lines at 33% of this value.

This can create a case where the minor grid lines are hard to see, and so you can also consider setting the minor grid lines at the same thickness of the axes, and then having the major grid lines 2\times this value.

Pattern #

You will also fin that people use patterns. That is, you can set the major and minor grid lines the same thickness (perhaps the same as the axis line) and then make the minor grid lines have a pattern, perhaps drawing them as a dotted line. This will use less ink for the minor gridlines, and so make them readily identifiable as such.

Color #

You might notice that in both the use of thickness and patterns, the minor gridlines had the illusion of being lighter in color. This is an optical illusion, but does give us an indication of yet another way we might differentiate the two. We can use the same thickness and pattern and then set the minor grid lines to be a lighter color than the major grid lines, which can be a way to retain uniform width and pattern, but still have things distinguishable.

Of course, you can combine all of these ideas, though I do think that, in general only one needs to be implemented at a time. Changing too many variables can lead to a bit of visual clutter, in my opinion.

You (mostly) do not need both grid lines and tick marks #

Grid lines and tick marks serve the same general purpose: to divide up the scale of the axis. Thus, both are not needed. A small design pet peeve of mine is when both are clearly present. By this, I mean when grid lines are present, and then so are tick marks, but with different designs. Perhaps grid lines are drawn in grey, and tick marks in black:

We do not need both elements. So, choose just one. Either use one or the other (as illustrated in all the plots above) or set the tick marks to be identical in design to the grid lines, so it just seems like the grid lines pass through the axis lines.

Conclusions #

All thinks being equal, I generally prefer tick marks to grid lines. If you look at the final plot on this page, and compare it to the second plot (using only tick marks), I think the second one is much more appealing.

However, as discussed above, there are reasons why one might wish to use gridlines. Additionally, there may be stylistic reasons to use them. To me, grid lines have a more “technical” or “engineering” feel, and so you might use them to evoke that. But again, without a good reason to use gridlines, I suggest using tick marks.