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 very 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 will show you how your dataset should look like. Additionally we have a few tips what to consider when creating a stacked bar chart.
Below is an example of a stacked bar chart:
1. Preparing and importing the data
The following dataset is used for the chart above. The row header has to contain descriptive labels that define the main category (first column), and categorical dimensions (other columns). The stacked bar chart can represent different categorical attributes.
Here is sample data from an actual survey (you can copy copy this table from this tutorial):
|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
Here is how your data should be formatted:
- Different values are marked by different color hues
- The size of each stack is determined by the value of its corresponding cell
- Each row is represented by a single stacked bar
In most cases you will be looking for a 100% stacked bar chart (as opposed to an absolute bar chart). This means that all values of each row have to add up to 100% (or 1). Check your data if that is the case. If not, check wether your data is flawed or should not be visualized in a stack bar chart. (One trick to avoid such issues is to add an extra column in your spreadsheet where you check the sum of all the data - the result should be 100 or 1.)
2. Check & Describe
This is what the table will look like after you uploaded it. Make sure that the box "First row as lable" is ticked so that Datawrapper correctly assigns the values to the labels. In our example the values are "Topic", "Very high trust", and so on.
Click on "Proceed" and Datawrapper will take you to the next step.
Choose the " Stacked bars". Note that the options avaible in the sections Refine, Annotate and Design will provide options specifically for the stacked bars, so it is worth exploring those. We cover this in a separate short tutorial found here.