How to create a stacked bar chart

Do you have answers from a survey and want to show the quantitative values of answers to different questions? Then the stacked bar chart is a great visual option to communicate the results.Using a stacked bar chart will let you show percentage proportions of all answers given with the help of color-coded categorical dimensions. The stacked bar is helpful because it reveals the pattern of how the answers where distributed. This tutorial shows you how to create a stacked bar chart.

1

Preparing and importing the data

If you want to create this chart type, your data needs to be in a certain format. You'll need:

  • One header row containing descriptive labels
  • One column containing categories. This will determine the label in front of each stacked bar. In our case, that's the topic. Each row is shown with a single stacked bar. 
  • At least two columns containing numeric values. Each number in your columns determine the length of the segment within the stacked bar. They will later be distinguished by colors. You can have as many numeric columns as you like, but they will be hard to read on mobile devices, so consider to aggregate your data into five or six columns. Consider the normal bar chart type if you want to display just one column with data.

That's the data we used to create the chart at the top of the page:

Topic Very high trust
High trust No answer Low trust Very low trust
Mediterranean Migrant Crisis 0.03 0.45 0.02 0.41 0.09
Protests of Islam critical PEGIDA movement in Dresden 0.03 0.37 0.04 0.41 0.15
Financial Crisis in Greece 0.04 0.31 0.02 0.46 0.17
Ukraine conflict between Russia and Western Countries 0.02 0.3 0.02 0.52 0.14

Source: Infratest  dimap

If you want to create a stacked bar chart in which all values within a row add up to 100% (so that all your bars have the same length), you don't need to upload the relative values – Datawrapper will let you stack the percentages up later in the chart creation process. For example, you could upload three numeric columns with the values 30%, 60%, 10%. Or you can upload three columns with the values 6, 12, 2 and stack them up to percentages later. The result will look the same. 

Once you prepared your data, create a new chart in Datawrapper. You can do so by going to our homepage and clicking on "Create a chart". In Step 1: Upload, copy & paste your dataset, upload it as a .csv or an Excel sheet.  After pasting the data above into Datawrapper, it will look like this: 

Click "P roceed" at the bottom right to go to the next step:
2

Check & Describe

In the second step, you can check if your dataset was imported correctly and make changes to it - if necessary. If you did not upload a header row, 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.

In step 2, your data looks like this. You can see that Datawrapper correctly recognized your numbers as numbers (and not as text or dates) because they are colored in blue and are right-alined. To learn more about the Datawrapper's automatic recognition of data formats, visit this article.

Click on "Proceed" at the bottom left to go to Step 3: Visualize:

3

Visualize

In this step, you see a first chart. It's probably a line chart. We want to change that. To do so, click on the "Stacked Bars" symbol at the top left of the available chart types:

You will now see a stacked bar chart, without a title, descriptions or customized colors. Maybe you want to further refine, annotate & define this chart. We cover this in a separate short tutorial found here.

Still need help? Contact Us Contact Us