This article describes how to create a stacked bar chart from an existing table like this:
To a chart like this:
The same process can be used to create a bar chart where the total does not add up to 100%. For example, the below chart was created using the same data as above, but replacing the percentages with the count for each cell:
Requirements
At least one of the following:
- A table with at least two columns and one row.
- Two variables
Please note this requires the Data Stories module or a Displayr license.
Method 1 - via the visualization menu
- Select the Visualization icon > Bar > Stacked Bar.
- Click on the page where you'd like to place the visualization.
- Under Data > DATA SOURCE > Output in 'Pages' select the table that you want to base the chart on. Alternatively, select the variable you'd like to base the rows of the chart on from Data > DATA SOURCE > Variables in 'Data'.
- Under Data > DATA SOURCE > Groups, select the variable you'd like to "stack" the rows on.
- OPTIONAL: If using variable inputs, go to DATA MANIPULATION, and tick Convert to percentages/proportions, unless you would like the total to not add up to 100%.
- OPTIONAL: Under Chart make additional changes to update the appearance of the visualization.
- Click Calculate and/or ensure that Automatic is checked.
Method 2 - using an existing table
- Select the table.
- From the object inspector, go to > Bar > Stacked Bar.
- OPTIONAL: Under Chart make additional changes to update the appearance of the visualization.
- Click Calculate and/or ensure that Automatic is checked.
Options
The following is an explanation of the options available in the Object Inspector for this specific visualization. Refer to Visualization Options for general chart formatting options.
Chart
APPEARANCE
- Gap between bars - Specify the amount of space between bars as proportion of the available space. Values can range from 0 (no gaps) to 0.99 (bars are shown as lines).
DATA LABELS
- Minimum threshold to show data labels - Data labels will be hidden in Stacked charts for values which are smaller than this proportion of the total range.
Note
Important information about editing captions:
Visualization caption edits may not be retained when a visualization with a nested table is switched back to table. Normally, this only occurs when you double-click the caption and edit the text directly. As a workaround, we recommend using Properties > CAPTION > Edit caption to edit your captions.
Next
How to Create a Bar Chart from a Table
How to Create a Clustered Bar Chart
How to Create Several Bar Charts Using Small Multiples
How to Customize the Color of a Single Category in a Bar, Column, or Pyramid Visualization
How to Apply a Gradient Palette to a Bar, Column, or Pyramid Visualization