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:
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:
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.
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:
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:
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.