How to show confidence intervals in Datawrapper line charts

Not all data is certain. Especially when polling just a subset of people, but also when measuring things like the temperature. We, as data visualizers, get confronted with a margin of error that results in a confidence interval. 

(To clarify terms: The margin of error tells us how much error we can expect, e.g., "10min too early or too late". The confidence interval tells us what that means for our data point, e.g., "between 4.50 and 5.10".)

To make sure readers get a true image of the data, it makes a lot of sense to visualize how uncertain it is. In this article, we'll learn how to create a confidence interval in Datawrapper line charts, like so:


1

Prepare the data

To create a line with a confidence interval, we need to upload four columns: 

  • the years
  • data points of the actual line
  • data points that will define the lower bound of the confidence interval
  • data points that will define the upper bound of the confidence interval

In our case, the data looks like this:

years temperature lower upper
1753 15.092 13.163 17.021
1754 14.681 12.28 17.082
... ... ... ...
2014 14.873 14.795 14.951
2015 15.051 14.965 15.137

We see that the confidence interval gets smaller, the better we learned to measure the global temperature. In the last years, the margin of error becomes even so small that we can't perceive it anymore in the chart.

After preparing the data, we can load it in Datawrapper. If you haven't created a line chart before, visit our article "How to create a line chart."

Once you've created a line chart, it looks like this:

There are two things to do to make sure it looks like our chart at the top of this article:


2

Fill area between lines

In the "Refine" tab, we'll find a lot of settings – but we're only interested in the ones at the bottom, "Fill area between lines". We click on "Add area fill" and choose the "lower" column for the "from" field and the "upper" column for the "to" field, like so:


3

Set line width to 0px

We're almost done! But our lines still look like lines, not like confidence interval areas in the background. That's why we now want to get rid of the lines. To do so, we scroll up to the "Customize lines" panel, and click on the lines next to "lower" and "upper" until they're set to 0px:


And that's it! We successfully made our margins of error visible.