Line charts

This module should take 30 minutes to complete.

When to use line charts

Line charts examine the relationship between two continuous variables.

Time series data

Time series data is when data points are spread out over a given time period.

Line charts are useful for time series data as they allow us to see trends.

Figure 1: Annual unemployment rate, all people aged 16 and over, UK, 1971 to 2021, seasonally adjusted

Larger version of figure 1.

This line chart allows us to see the highs and lows of the unemployment rate. It shows the fluctuations of the rate between a high of just under 12% in the early 1980s and a low of just under 4% in 2019.

Source: Labour Force Survey from the Office for National Statistics

Back to top of page

Line chart formatting

Do not use 3D line charts

Figure 2: Fictional data for England and Wales

Larger version of figure 2.

This figure shows two line charts of fictional data for England and Wales. One is a basic line chart, one is a 3D line chart. The basic one has a green tick above it, the 3D one has a red cross above it.

We advise never to use 3D line charts because it is hard to read accurate values from them.

For example, when you try to read the peak of the England line on the 3D chart it is hard to tell when the peak took place and what value was reached.

Line thickness

Make sure lines are not too thin.

When lines are too thin they become difficult to see.

We cannot give a specific line weight to use as it will depend on how you make your chart and what it looks like in your final document or webpage.

Figure 3: Line thickness

Larger version of figure 3.

This figure shows two line charts of data for men and women. The left chart shows two clear lines, and the right chart shows very thin lines that are harder to see. The left chart has a green tick above it, and the right one has a red cross above it.

Legends and labelling

As mentioned in previous modules of this e-learning, the accessibility success criterion for ‘Use of colour’ states that colour should not be used as the only way to communicate a message.

Chart legends can be tricky to make accessible as most of the time, the only way to match a label to the relevant line or bar is by using colour. Some users will find this difficult.

With line charts you can label lines on the chart itself. If you do this, try to avoid the gridlines.

Alternatively, you can put labels at the end of the lines.

Figure 4: Options for labelling lines

Full size version of figure 4.This figure shows two versions of the same line chart displaying the different options for labelling lines. The left chart shows labels above and below the lines and the right chart shows labels at the end of the lines.

Demonstration video

Watch this video to see how to add labels to lines directly in line charts


I’m going to talk through labelling lines directly in charts.

We recommend doing this because the web content accessibility guidelines say not to use colour alone to communicate information.

At the moment, by having a legend we are relying on our users being able to connect the ‘Men’ label with the line to interpret it. However, some users might have difficulty using legends due to colour impairments or other impairments.

First, I start by deleting this legend.

Next, I go to ‘Insert’, ‘Text box’ and draw a text box next to this line I’m going to be talking about. Then, I add text to this text box to say ‘Men’. The text is slightly small so I’m just going to up that to font size 20 to be the same size as the text on the axis.

Next for the orange line, I go to ‘Insert’, ‘Text box’ and draw a textbox next to the orange line. This line represents women, so I add that to the text label. Again, I increase the size of the font to 20.

And there we go, we’ve updated the chart, so we are no longer relying on colour alone to be able to interpret this chart.

 

Coloured text

Generally it is better to stick to black text on a white background than use other text colours. This is not perfect for all users but given current technology for publishing charts, it is the best we can do.

However, when lines are very close together it may be clearer to use coloured text.

If you do need coloured text, you will need to consider the contrast ratio between the text and the background. This online contrast checker (link opens in a new tab) can help you.

More information on colours and accessibility can be found in earlier modules of this e-learning.

Data markers

Data markers are small shapes on lines that depict the data points.

We advise caution when using data markers as large data markers or the overuse of them can make a chart cluttered.

Remember: a chart is there to tell a story, not to provide high levels of detail and precision.

Figure 5: Annual unemployment rate for men and women aged 16 and over, UK, 1971 to 2021, seasonally adjusted (with data markers)

Larger version of figure 5.

This line chart shows two data series with data markers added in. They are not needed to understand the story. They add unnecessary clutter.

Source: Labour Force Survey from the Office for National Statistics

Sometimes data markers are used to differentiate data series. If used alongside colour to differentiate chart elements this does meet the relevant accessibility success criterion. But, they are still not considered best practice due to the extra clutter they add which can make charts harder to understand for everyone. So, if you use them, use them carefully.

There’s more information on accessibility in previous modules of this e-learning.

Textured lines

Textured lines are dotted or dashed lines.

Figure 6: Annual unemployment rate for men and women aged 16 and over, UK, 1971 to 2021, seasonally adjusted (with textured lines)

Larger version of figure 6.

This line chart has two lines. The line for men is dashed, the line for women is dotted.

Source: Labour Force Survey from the Office for National Statistics

We advise caution when using textured lines because:

  • they can make a chart cluttered
  • they may be misinterpreted as showing incomplete, forecasted or provisional data, a target or a subcategory

As with data markers, textured lines are sometimes used to differentiate data series. If used alongside colour this does meet the relevant accessibility success criterion. But, they are still not considered best practice due to the extra clutter they add and the misinterpretation they can lead to. So, if you use them, use them carefully.

As mentioned, there’s more information on accessibility in previous modules of this e-learning.

Colours

Colours for two lines

When choosing colours for chart elements we must refer to the Web Content Accessibility Guidelines (WCAG). Particularly the following success criterion:

1.4.11 Non-text Contrast: The visual presentation of parts of graphics required to understand the content have a contrast ratio of at least 3 to 1 against adjacent colours except when a particular presentation is essential.

This means all chart elements that are adjacent must have a contrast ratio of at least 3 to 1, unless the presentation is considered essential. Contrast ratios measure the brightness between two colours. This online contrast checker (link opens in a new tab) gives more detail.

We advise you to use the colour palettes in our colours guidance (link opens in a new tab).

Remember: all chart elements are adjacent to the background colour.

Figure 7: Annual unemployment rate for men and women aged 16 and over, UK, 1971 to 2021, seasonally adjusted (line colour)

Link to full size image of figure 7.

The line chart shows the men’s unemployment rate in dark blue and the women’s in orange. This allows us to see how the trends in the unemployment rate have differed for men and women between 1971 and 2021. The chart also has a green tick above it.

Source: Labour Force Survey from the Office for National Statistics

The blue and orange are from the categorical colour palette in our colours guidance. These colours have enough contrast with each other and with the white background to pass the relevant accessibility success criterion.

Colours when there are more than two lines

When line charts have more than two lines it is not possible for each line to have high enough colour contrast with the white background and with all other lines.

This is not a fail of the accessibility success criterion as long as the presentation of four lines is considered essential. See the wording of success criterion 1.4.11 Non-text Contrast (link opens in a new tab).

However, when this is the case we should help users in all other ways we can:

  • make sure all colours have a high enough contrast with the white background – this ensures all lines have a good chance of being seen, even if they cannot be differentiated
  • give a plain text version of the chart, either as a text description or as a table of data – note: we should do this for all charts, but it is particularly important in this situation
  • whenever appropriate, make sure lines are labelled directly and that legends are not used – note: we should try to do this for all line charts but it is particularly important in this situation
  • consider a different type of presentation such as a series of small multiple charts

More information is in our colours guidance (link opens in a new tab).

Figure 8: Annual revenue of four fictional companies, 2010 to 2020

Larger version of figure 8.

This line chart has four lines. Each line represents the annual revenue of a fictional company. The colours used are from our recommended colour palette for categorical data. All colours have a high enough contrast with the white background but the dark blue does not have a high enough contrast against the dark pink and the orange does not have enough contrast against the turquoise. The lines are labelled directly so no legend is used.

Back to top of page

Line chart considerations

Correlation is not causation

Line charts are often used to show multiple variables on the same axes. They can often display correlation.

But remember: just because two lines follow roughly the same pattern it does not mean one variable caused changes in the other:

Correlation does not equal causation

Think about what your chart might be suggesting and if it could be potentially misleading.

The image in this tweet shows a line chart displaying the divorce rate in Maine and the per capita consumption of margarine on the same axes. One is not causing the other but the lines follow the same pattern over the time period shown.

This chart is from a collection of spurious correlations on this webpage (link opens in a new tab).

Limit of four lines

We advise a maximum of four lines on a line chart. More than four lines can make it hard to see the message of the chart.

Figure 9: COVID-19 cases per million people in selected European countries, 7-day rolling average, by date reported, 1 August 2021 to 14 November 2021 (original chart)

Larger version of figure 9.

This line chart has eight lines, each showing a European country. The chart has a red cross above it.

It shows COVID-19 cases in the UK have been relatively steady over this period. It also shows cases and Austria and Belgium and the Netherlands had started increasing sharply towards the end of the period. Finally it shows that cases in Germany were rising at the end of the period, but cases in France, Italy and Spain were relatively flat.

But this chart is cluttered and it is unclear what message a user is meant to focus on.

Source: Coronavirus (COVID-19) cases taken from Our World in Data

Focus chart alternative

Use a focus chart when the story of the chart is about one particular line and how it compares to the others in general.

We recommend the dark blue from our categorical colour palette for the line of interest. We also recommend you make this line slightly thicker. We recommend a light grey for the other lines. We recommend this colour because we want these lines to be less obvious. This helps us emphasise the series we are interested in.

The dark blue has a high enough contrast with the white background and the grey. But, the grey does not have a high enough contrast with the white background.

This is not a fail of the accessibility success criterion as long as the presentation of a focus chart is considered essential. See the wording of success criterion 1.4.11 Non-text Contrast (link opens in a new tab).

Figure 10: COVID-19 cases per million people in selected European countries, 7-day rolling average, by date reported, 1 August 2021 to 14 November 2021 (focus chart)

Larger version of figure 10.

The line chart on this slide has eight lines, each showing a European country. The chart has a green tick above it. The line for the UK is dark blue. The lines for all the other countries are light grey. This allows us to focus on the UK and how it compares with the other European countries on the chart.

We can see the UK’s line was at a consistently higher level compared with the other European countries, but the sharp increases seen in Austria, Belgium, Netherlands and Germany towards the end of the time series had not yet occurred in the UK.

Source: Coronavirus (COVID-19) cases taken from Our World in Data

Small multiples alternative

Small multiple charts allow us to see trends for different groups in a set of small charts.

They are useful in terms of digital accessibility as there are fewer colour contrast requirements to think about.

It is essential for all the y-axes to have the same scale and all charts to be the same size. This will avoid misunderstandings.

To reduce clutter, label the y-axis once in each row. You may not need a y-axis label for units if it is clear from the title.

Finally, make sure the charts are spaced out evenly.

You can create these using Microsoft Excel and PowerPoint. You can also use programs like R.

How they look when published will depend how you publish them. They can look very small. It is a good idea to get feedback on them to make sure they are readable.

Figure 11: COVID-19 cases per million people in selected European countries, 7-day rolling average, by date reported, 1 August 2021 to 14 November 2021 (small multiples)

Larger version of figure 11.

This figure shows all the lines in the previous charts about covid cases on smaller, individual axes. There is a green tick above the charts. Showing the data as multiple small charts allows us compare the countries.

Source: Coronavirus (COVID-19) cases taken from Our World in Data

Examples of small multiples

Line charts crossword puzzle

Test out your knowledge so far.


Breaking the y-axis in line charts

Unlike with bar charts, breaking the y-axis on a line chart is sometimes a useful and valid thing to do.

It can help draw attention to a message. But, you must make the break clear.

This is not always easy to do, depending on the software you use to create charts.

Lets consider a chart where it would be useful to break the y-axis:

Figure 12: Percentage of children immunised against Diphtheria and Measles Mumps and Rubella (MMR) by their second birthday, England, 1991 to 2013

Larger version of figure 12.

This line chart has two lines. The y-axis starts are zero. There is a lot of white space at the bottom of the chart. The lines look fairly flat.

Source: Childhood vaccination coverage statistics from NHS Digital

Lets break the y-axis to start at 70%:

Figure 13: Percentage of children immunised against diphtheria and Measles Mumps and Rubella (MMR) by their second birthday, England, 1991 to 2013 (broken y-axis)

Larger version of figure 13.The chart is the same as figure 12 but this time it has a y-axis which starts at 70%. The chart has a red cross above it.

Starting the y-axis at 70% allows us to draw attention to the message of the chart as it zooms in on the data. But, the break in the y-axis is not clear.

How to change the y-axis minimum bound in Microsoft Office programs

  1. Click on the y-axis, then right click and select “Format Axis” – this should bring up the sidebar.
  2. Select the bars icon at the top of the sidebar.
  3. Under “Bounds” type in what you want the minimum bound to be.

Making the break in the y-axis clear

Give the y-axis a line
  • Click on the axis, then right click and select “Format Axis”.
  • Click the paint pot icon at the top of the sidebar.
  • Under “Line”, click “solid line”, select a dark grey colour and increase the weight slightly.
  • The colour and weight you need will depend on your chart – take care, you want to axis line to be visible but not distracting.
Hide the minimum value
  • We want the break to illustrate the axis starts at zero, then breaks and starts at the next gridline value.
  • This means we need to hide the minimum value on the axis.
  • At the moment the only way to do this with Microsoft Office programs is to insert a white square with no border and cover the minimum value with it (in this case the white square will cover the 70 value).
Indicate the break
  • Insert two parallel, diagonal lines across the axis between the minimum and the first gridline (other types of symbol are sometimes used, but this is the easiest to create).
  • These lines should be the same colour and weight as the axis line.

Figure 14: Percentage of children immunised against diphtheria and Measles Mumps and Rubella (MMR) by their second birthday, England, 1991 to 2014 (break shown with symbol)

Larger version of figure 14.

 

The chart shows the same data as figure 13 but the y-axis now has a symbol to indicate it breaks between zero and 75%. This chart also has a green tick above it.

This chart shows the message in the data more clearly than when the y-axis started at zero.

The message the chart shows is that the percentage of children immunised against Diphtheria fell from 93% in 1995 to 90% in 2004. The drop in the percentage of children immunised against MMR was bigger, from 92% in 1995 to 80% in 2003.

Both rates recovered but in 2013 the percentage immunised against MMR (93%) remained below the percentage immunised against Diphtheria (94%).

We can improve this chart further by adding in annotation to explain the context. See the example in our line charts section of our charts guidance (link opens in a new tab).

Dual axis line charts

Dual axis line charts can be used to present two variables with differing scales.

In general, we do not recommend using dual axis charts because:

  • they can be easily misinterpreted
  • the way we display lines in relation to each other can manipulate the data story, even if it is not intentional

The ONS digital blog post on “Dueling with axis: the problems with dual axis charts” provides more information on how dual axis can mislead users.

Misinterpretation example

Figure 15: Employment and unemployment rate for people aged 16 to 64, UK, seasonally adjusted

Larger version of figure 15.

This is a dual axis chart showing the employment rate using the y-axis on the left hand size and the unemployment rate using the y-axis on the right hand side. The employment rate is generally rising from around 72% in 2009 to around 76% in 2022. The unemployment rate is generally falling, from around 7% in 2009 to around 4% in 2022.

Source: Summary of labour market statistics from the Office for National Statistics

Charts like this can be easily misinterpreted. Possible messages a user might get from this chart are:

  • The unemployment rate exceeded the employment rate between 2009 and 2015.
  • The employment rate is now about twice as high as the unemployment rate.

Manipulation example

Dual axis line charts can be manipulated to show almost any relationship.

Figure 16: Example of how dual axis charts may be manipulated

Larger version of figure 16.

This example has six dual axis line charts. It starts with a faithful representation of the data – fairly flat lines spaced far apart. It then displays the other ways these lines could be shown. These are: lines crossing over, lines converging and diverging, lines separate and then converging, one stable line with lots of change in the other.

Quick practice on dual axis manipulation (PPTX, 177KB).

If you have any problems accessing or using this file please email Analysis.Function@ons.gov.uk.

Dual axis line chart – alternative

Figure 17: Employment and unemployment rate for people aged 16 to 64, UK, seasonally adjusted (using two separate charts)

Larger version of figure 17.

This figure shows the same data as figure 15 but now we have used two smaller charts to show the employment and unemployment rates on separate axes. We have also added in annotation explaining that at the start of the coronavirus (COVID-19) pandemic employment rates fell and unemployment rates rose.

Source: Summary of labour market statistics from the Office for National Statistics

Note that we have made it clear that the y-axis does not start at zero for the employment rate chart.

This presentation is less likely to be misinterpreted or manipulated. It draws attention to the changes in the rates.

Breaks in time series

Breaks in time series can occur due to missing data points and changes in methods.

The best way to deal with discontinuity varies depending on the data and the story you are telling. But, it must always be highlighted.

You do not always have to use a line for a time series with a discontinuity. Displaying the data as individual points may be better.

If you do use a line, do not join the points either side of the missing data point, even if the line is dotted or dashed. Joining points implies we know something about the data.

Figure 18: Example of time series with a break (fictional data)

Larger version of figure 18.

This figure shows two line charts. Both have a discontinuity. One leaves a gap in the line and marks out the gap with two vertical dashed lines and annotation stating the data was not collected in 2020 due to the coronavirus (COVID-19) pandemic. This has a green tick above it. The other shows joins the gap with a dashed line. This has a red cross above it.

Examples of breaks in time series

Aspect ratios 

The aspect ratio of your chart is the ratio of the chart width to the chart height. In line charts, the aspect ratio you choose alters the slope of the lines. This can be misleading.

We are not able to give a specific aspect ratio that will work for all line charts. But, this article on chart aspect ratios proposes you choose one that makes your line chart “appear reasonably neutral, without either making the changes appear too extreme (by picking an aspect ratio that is too small) or too flat (with an aspect ratio that is too high)”

Example: how different aspect ratios affect line charts

Large version of chart showing how different aspect ratios affect line charts.This example shows the same line chart with three different aspect ratios. Chart 1 has a neutral ratio, this is the best way to present the data. Chart 2 has a high aspect ratio which makes the data look too flat. Chart 3 has a low aspect ratio which makes the data look too extreme.

Line chart example

Example 1 in our guidance showing data visualisation examples demonstrates how to apply this guidance to a real-life line chart.

Back to top of page

Quiz

Try these questions to test your knowledge from this module

 

Download a plain text version of module 8 quiz (ODT, 9KB)

End of module 8

Next, module 9: Pie charts.

Back to landing page.

Back to top of page
  • If you would like us to get in touch with you then please leave your contact details or email Analysis.Function@ons.gov.uk directly.
  • This field is for validation purposes and should be left unchanged.