How to create a stacked bar chart
- Free
- Pro
- Business
- Enterprise
A stacked bar chart is a great choice to show relative or absolute shares within categories. This article explains how to create and customize a stacked bar chart.
Preparing your data
Formatting your 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 as a single stacked bar.
- At least two columns containing numeric values. Each number in your columns determines 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.
Uploading your data
Once you've 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 Sheet. After pasting the data above into Datawrapper, it will look like this:

Click Proceed at the bottom right to go to the next step.
Checking data and units
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 in the image 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 Datawrapper's automatic recognition of data formats, visit this article.

To add a unit (like km/h, kg, inches, $, etc.) to your numbers, click on a column header and then add the unit of your choice to the Prepend/append options on the left. You can learn more about adding units to numbers here.
Click on Proceed at the bottom left to go to Step 3: Visualize.
Choosing a stacked bar chart
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 let you further refine and annotate this chart. Besides Chart type, you'll notice three more tabs in this step: Refine, Annotate, and Layout.
Refining your chart
Resizing
In any tab of step 3: Visualize, you can click, hold, and drag the arrow in the lower right corner to scale the chart window or manually determine the dimension of the chart by entering values in the boxes below the chart (Size).
We recommend checking what the chart looks like on different screen sizes multiple times while designing it, by clicking on the little icons (mobile, tablet, and computer) below the chart.

Learn more about changing the width and height of your chart in this article.
Formatting labels

Let's continue with the Refine tab. Here, we see four panels: Labels, Horizontal axis, Appearance, and Sorting & Grouping.
The first panel lets you choose how you want your labels to look. Do you want to align your labels to the left or right? Display them in a separate line? Show or hide the value labels? Feel free to play around with these settings to see what works best for your data (don't worry, you can't break anything – just change it back if you're not happy with the setting).
In this example, the chart is showing two opposite extremes: "Very high trust" and "Very low trust". In a case like this, it's good to select diverging for Value alignment. This will center-align the middle category (No answer) and right-align the labels of the two categories. This helps to communicate that the chart is showing two opposed positions.
Now, the most interesting setting in this panel is the Number format. Here we can decide how our values are shown (if we chose to display them). Here are three examples:
- Choose the number format "123.4k" if you have big numbers like "1,303,428" that you'd rather want to display as "1.3m"
- Choose the number format "0.0" if you have very detailed numbers like "0.1922302" that you'd rather want to display as "0.2"
- Choose the number format "0%" or "0.0%" if you have a number that is a relative number. This setting will add a percentage sign. (In our chart, you'll notice that the Number format setting cannot be customized. This is because the chart is set to 'Stack percentages' (a feature that will come up later in this article) so the values are automatically normalized to 100%.)
If you want a more detailed explanation, you can also read our Docs article Number formats you can display in Datawrapper.
Changing the axis range

The second panel lets you customize your horizontal axis and grid lines.
- Custom range: Here you can decide which value range your x-axis should cover. By default, the x-axis will be as long as the sum of all values within a row. (In our chart, we've checked the Stack percentages option, so Datawrapper will automatically stack the bars up to 100% without having to enter a custom range.)
- Grid lines: You can choose to show vertical grid lines along the x-axis and where to position them. You will see more options when you switch on the Grid lines feature. (In our chart, we turned on the 'Move labels to separate line' feature in Labels panel, which is why the grid lines are automatically added without turning it on here.)
Changing bar colors and appearance

In the third panel in the tab "Refine", we can decide the design of our stacked bar chart: We can choose bar colors and decide if we want to separate rows with a line, make our bars thicker or stack the percentages.
Let's focus on how to choose colors for our bars. We can choose one color for all our bars (click on "Base color" to change the default color). We can also adjust the colors manually. This will help us to make the stacks more distinguishable. To do so, click on customize colors next to the base color.
If you're working with surveys and have two opposed extremes like this example chart, we recommend to tone down the neutrals like "No answer" (e.g., with gray), and make the extremes more clearly stand out.
You can select and give the same color to multiple bars at the same time by highlighting them together. (If you want to highlight multiple items that are listed consecutively, hold down the Shift key while selecting. If the items are not in consecutive order, hold down the Ctrl (Windows) or Command (Mac) key while selecting.)
You can also select colors by clicking on the colored boxes, choose different gradients of the same color or manually enter Hex color codes (e.g. #15607a is a dark blue, #15607a50 is a dark blue with 50% opacity).
Below the Appearance panel, you will find a Stack percentages checkbox, which normalizes values to 100%. That means you can upload absolute values (“350 people liked it, 150 disliked it”) and then convert them to percentages directly in Datawrapper (“70% liked it, 30% disliked it”).
Also, make sure that the Color key is ticked so that the reader can identify each color code.
Sorting and grouping bars

In the fourth and last panel in the tab Refine, you can sort and group bars. The default setting for the order of the bars is the order that was in your spreadsheet but you can change that here.
- Sort bars: By turning this on, you can sort the bars in numeric order. So you'll have the largest bars/values at the top and the smallest bars/values at the bottom. In our example, you can sort your charts by one of your columns, e.g. "Low Trust". The biggest value in this column will then be at the top.
- Reverse order: This will do the opposite of "Sort bars" and you'll have the smallest bars/values at the top and the largest bars/values at the bottom.
- Group bars by column: You can upload an extra column to assign groups. If you want a step-by-step guide on how to create grouped bar charts, please refer to our tutorial How to create a grouped bar chart.
Annotating your chart
Adding a title and source

In the Annotate tab, you're first asked to give your visualization a title, description, notes, source, byline, and an alternative description for screen readers. You can find a detailed explanation of all these Annotate options here.
Highlighting bars

In the 2nd panel in the "Annotate" tab, we can choose to highlight elements: The label in front of or above these bars will appear in bold. We can revert the highlight by clicking on the "x" on the left side of the label.
Adding text annotations

You can add annotations to your stacked bar charts by clicking on Add text annotation. You can then style and move the text, add an arrow and circle to it, and adjust how it will appear on mobile.
Highlighting ranges

You can add a range or line highlight by clicking on Add range highlight and then dragging on the chart where you want the highlight to be. You can then change its position, color, opacity, and line width and style, or delete it again. Here's an in-depth explanation of all the options.
Publishing your chart
In the Layout tab, you can select an output locale, change the design theme and footer options, and enable social sharing. Find a detailed explanation of all the Layout options here.
In the final step 4: Publish & Embed, you have the option to publish the chart either by sharing the URL or by pasting the embed code directly into your website or CMS (recommended). You can also download your chart as a PNG (available to all users regardless of the type of subscription plan they have) or as an SVG or PDF (available only to users of paid plans). For more information on the different pricing plans, click here.
And that's it! You've successfully created and customized your first stacked bar chart.