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 the answers given with the help of color-coded categorical dimensions. The stacked bar is helpful because it reveals the patterns of how the answers are 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 aggregating your data into five or six columns. If you only have one column with data, a better alternative could be a simple bar chart.

Below is 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 "Start creating". In Step 1: Upload, you can either copy & paste your dataset directly or upload it as a .csv or as an Excel or Google Spreadsheet.  After pasting the data above into Datawrapper, it will look like this: 

Click ''Proceed" 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 should look something like the figure below- automatically arranged in columns and rows. 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-aligned. 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

Under the tab ''Chart type'', you will see a grid of chart types displayed. Odds are that your data will automatically be displayed as a line chart. To change that, click on the "Stacked Bars" symbol in the grid of available chart types:

You will now see a stacked bars chart without a title, descriptions or customized colors. The next step would be to further refine, annotate & define this chart. We cover this in a separate short tutorial found here.