How to group bars in a bar chart
The bar chart is probably the most all-rounder chart type out there. But sometimes, your bars fall into categories (like continents, regions or countries, positive or negative growth or years), which you want to show to make your statement. Grouping bars in a bar charts are great for that, and for bringing some visual structure into your bars.
You can use this guide for the following chart types: bar chart, stacked bars, grouped bars, split bars, bullet bars, and even dot plots, range plots, and arrow plots. Grouping your bars (or, more generally, rows) works in all of them.
👉 To learn how to create our chart type grouped bar chart, we'll publish a guide soon.
👉 If you want to create a simple bar chart in Datawrapper, please read How to create a bar chart.
In this tutorial, you will learn how to prepare and upload your dataset to group bars with Datawrapper.
Preparing and importing the data
Your data needs to be in a certain format for Datawrapper to group bars. You'll need three columns:
- Descriptive labels in the first column.
This will determine the label in front of each bar. In our case, these are the countries. - Corresponding values in the second column.
These values need to be numeric in order to determine the length of each corresponding bar. In our case, the values are road fatalities. - Categories in the third column.
With these categories, you decide what each bar will be grouped by. In our example, we chose to group the countries by continent.
Country | Road fatalities per 100,000 motor vehicles | Continent |
Mexico | 43 | North America |
Italy | 7.3 | Europe |
Switzerland | 4.7 | Europe |
Singapore | 20.2 | Asia |
- These columns don't need to be in this exact order. Datawrapper will use the column with the numeric values for the bar length – no matter if it's the first, second or third column.
- You can upload more than three columns and later choose which column you want to set as your labels, values, and groups.
- The rows don't need to be in the exact order. You can sort them later.
- Make sure that the category names don't include unnecessary white space. For example,
Europe
andEurope
will be interpreted as two separate groups.
Check & Describe
In the second step, you can check if your dataset was imported correctly and make changes to it - if necessary. If you don't have a header, you have to untick "First row as label" to avoid losing your first row of data. Always remember to do this if you don't have descriptive row and column headers.
By selecting a certain output locale, Datawrapper chooses the correct decimal and thousand separators for you.
Click on "Proceed" to get to the visualization process.
Visualize
In this section, you have four tabs: Chart Type, Refine, Annotate and Layout. You can choose any of the following chart types: Bar Chart, Stacked Bars, Grouped Bars, Split Bars, Bullet Bars, and even Dot Plots, Range Plots, and Arrow Plots. Grouping your bars will work in any of them: When you click on Bar Chart, you will see your data in form of a bar chart – although your bars won't be grouped yet. You will need to tell Datawrapper that you want them grouped. To do so, click on the tab Refine. At the bottom, you'll see the feature Group bars by column. If it's not already open, click on it to open this feature and you will see the following options:
Here you can choose which column you want to have your bars grouped by. Since we want the bars to be grouped according to the continent, we will select "Continent". You also have the options to show group labels and bar labels too. Try them out yourself to see what happens!
Now you've arrived at a bar charts with grouped bars. From here you can customize your chart. We cover this in the following article: "Customizing your bar chart".