Lines #
Thickness, patterns, and color are all ways to achieve contrast between lines. Of these patterns and color are likely your best options.
Realizing contrast in lines #
It will often be the case that you have data visualizations with several different lines. This is obviously the case when you have a line plot with two different data series present. But, it is also true whenever you have a data visualization that has both x and y axes shown.
Whenever you have multiple lines you need to consider which you want to look the same and which you want to look different. In other words, you have a question concerning consistency and contrast. This also means that you need to understand how to realize contrast between lines—what makes lines look different from one another. This is the topic of this article.
We will consider three different aspects: thickness, color, and pattern. In the absence of differences in these properties, we cannot distinguish between lines on a plot.
Here, there is not even contrast between the lines that represent data, and the lines that represent information about the axes. To my eye, this creates a somewhat confusing graph, where it is not quite clear what the reader should be looking at. Most modern plots will, for this reason, make the data lines thicker than the axes lines, which leads us to our first form of attaining contrast.
Thickness #
For the above plot, if we make the data lines double the thickness of the axes lines, we have a plot that, to my eye, makes it much more clear where the focus is.
But this still doesn’t really help distinguish the data lines. Interestingly, we really don’t need to make “income” appear different. Since this line never crosses another, we can clearly assign the label to a single line. But for the housing and education costs, the story is different. We might imagine that education costs are increasing steadily, but we don’t actually know which one of these costs has the dip around 2011. We can distinguish between them by increasing the thickness of one of the lines.
Now, it is quite clear that the education costs are the ones that are rising steadily.
Some people might find it odd that we only changed one of the line’s thicknesses, and this is a valid point. By having only one line with different thickeness, it seems to empahsize this line over the others. If we instead make all three different thicknesses, it de-emphasizes the most thick line.
Note that, when adding in a new thickness, I preserved the largest difference in thickness for those lines that cross, helping creating more contrast at the point where it is most needed.
Though this use of three different thicknesses does help alleviate the problem of emphasizing the education costs, it doesn’t entirely remove it. This is just how humans are: we will notice things that are larger than others and ascribe to them more importance. Of course, if you want to draw attention to a particular line, then thickness is a great way to do this. However, if you wish to try to avoid this effect, while still creating contrast between lines, you can turn to line patterns.
Pattern #
When thinking about line patterns, they are typically given names like “dot” or “dash” or “solid”. We can show a plot with all three present.
Now we can again tell these three lines apart. We do have a small problem in the fact that the dotted line has less visual weight than the others, and so may be de-emphasized some. But it is perhaps a bit less strong than when using widths.
There are a few things to keep in mind when using patterns. First, is to remember that contrast in patterns comes from the difference in the length of the ink and the length of the white space. Thus, controlling the differences in these elements will allow you to control the degree of contrast you have. Consider the following plot:
Now the two crossing lines both have dashed patterns, though they are slightly different. The contrast is still good enough that we can tell them apart, but not as strong as they were above.
Second, it is important to understand that, as implemented by default, dot and dashed patterns naturally introduce white space, or missing data, into the line. Thus, the more empty space you introduce into a pattern, the more you are likely to obscure features in the data. Consider if we simply swap the dash patterns above:
We have now added the pattern with the most missing space to the data with the most variability in the values. This has the effect of “smoothing” out the data, as we are missing many of the changes. Compare this to the plot above, or the plots where this is a solid line. Thus, if you turn to patterns, it is extremely important to understand that you might be obscuring features of your data.
Of course, there is a way to try to remedy this. You might consider not simply using missing ink, but using ink of a different value. Perhaps a light grey. This will return the features, though they will still be a bit harder to see:
Of course, adding back in ink also reduces the contrast within the pattern, and so reduces the effectiveness. Thus, it might be worth considering even other ways to realize contrast in lines, which leads us to consideration of color.
Color #
Just as discussed when talking about creating contrast in data markers, we can consider generating contrast with the three aspects o color: hue, saturation, and value.
Saturation #
Probably the weakest channel for contrast is saturation. Here is an example of the plot, where the saturation varies by steps of 25% between lines.
The lines are arranged such that the two lines that cross differ by the largest amount, 50%, but it is still relatively hard to tell the two apart.
Value #
We can attain more contrast by altering the value of the color. Below is a plot where the value changes by increments of 25%. Again, the largest difference (50%) is between the lines that cross.
It is clear that greater contrast is achieved when using value, as compared to using saturation. Thus, this is not a bad choice for distinguishing between lines—especially if you are wishing to use a monochrome palette or you want to try to encode a quantitative variable to the colors.
Hue #
Even though the contrast is fairly good between the lines that differ in terms of value, you can usually attain even better contrast when changing hue. Below is the same data, but now there is no difference in saturation or value, but there is in hue.
To my eye, these are the simplest to tell apart. Also, it is worth noting that the two lines that cross are not even as far apart as they could be in hue space, but were chosen to be a split complementary color, to emphasize the connection between the two categories associated with cost, while accentuating the difference from income.
Of course, when relying on hue, one should be careful to ensure that the colors chosen are accessible (e.g., they are colorblind friendly), but as long as you do so, the changes in hue are an excellent way to encode categorical differences.
Degree of contrast depends on size #
As always, it is very important to realize that the degree of contrast you attain by changes in any parameter is dependent on the size of the features. Consider the above changes in hue, which produced good contrast. If the lines were very thin instead, you will get the plot below.
In this image, looking at only the lines, it would be quite hard to tell the difference between the lines that cross. However, the hue has not changed—just the thickness of the lines.
Other lines #
It is worth recalling that there are many other types of lines than data lines. Lines of the axes and gridlines are just two such examples. All of what was discussed above are ways to also alter the contrast between these elements and all other lines within the visualization. This could be used, for instance, to de-emphasize contrast of the axes. Below, the lines associated with the axes has been changed to light grey, which makes them fade more into the background, and puts emphasis even more on the data lines.
For consistency, one might also change the tick marks and tick labels and axes titles to be the same light grey, but since we are discussing only lines here, we have changed only them. The point is that one can consider all the lines in the plot, and make choices regarding their appearance to place focus where you want it.
Conclusions #
The general guidelines for designing lines is the same as for any other element of a graphic. You want to consider where you want to direct attention and what connection you want the viewer to see between the line on the page. Then you choose the parameters in order to differentiate between lines, or have them look similar, all in service of communication. Bringing this all together, imagine we wanted to draw the connection between the categories that are expenses, and then wanted to emphasize the income line. One way to do this is to keep the color palette above, and then make the income line thicker, like shown below:
Thus, you can see that the ideas outlined above can be combined in service of the story you are telling.