Stacked bar charts display the relative size—either as a count, percentage, or other numeric variable—of a categorical variable, subdivided by color based on a subgroup.
Stacked bar charts can answer questions about your data, such as How are numeric values distributed or summarized by category and subcategory? How is your data ranked?
An insurance company is reviewing the types of policies it offers to compare its current offerings to the findings from a recently completed market research project. The insurance company is especially interested in expanding its business in five cities of interest. A stacked bar chart can be used to visualize the sum of total insured values (TIV) for each city of interest and policy class.
The analyst is interested to see that Miami has the highest TIV, despite having approximately half the population of Jacksonville. Based on these values, it seems like Jacksonville could be a good choice for expanding business. The analyst will also look closer at advertising and competition in Miami so she can create a strategy for the other cities.
The company believes it may be able to break into new markets by advertising bundle options to existing customers. The marketing team thinks it would be best to customize which bundles are promoted for each city based on which policy classes are being under-purchased. The analyst can determine which bundles to promote in each city by changing the numeric variable on the stacked bar chart from the sum of TIV to the count of policies and displaying the chart with a stacked percent. The changes to the chart allow the analyst to determine the proportions of policies sold from each class for the cities of interest.
The chart shows that most of the cities have at least one policy class with a very low percentage of the overall count of policies for the city. For example, Jacksonville and Saint Petersburg have no policies in the Automobile and Property classes, respectively. The company could try to increase the sales of those policy classes by advertising insurance bundles to existing life insurance customers, which make up a relatively high proportion of the policies in both Jacksonville and Saint Petersburg.
Create a stacked bar chart
To create a stacked bar chart, complete the following steps:
- Select one of the following data options:
- Two string fields
- Two string fields plus a number or rate/ratio field
If you do not select a number or rate/ratio field, your data will be aggregated and a count will be displayed.
- Create the stacked bar chart.
- Drag the selected fields to a new card.
- Hover over the Chart drop zone.
- Drop the selected fields on Stacked Bar Chart.
You can also create charts using the Chart menu above the data pane or the Visualization type button on an existing card. For the Chart menu, only charts that are compatible with your data selection will be enabled. For the Visualization type menu, only compatible visualizations (including maps, charts, or tables) will be displayed.
The Legend button can be used to select data from the subgroup. To change the color associated with a category, click the symbol and choose a color from the palette, or enter a hex value.
The Style tab can be used to change the layout between Stacked Count and Stacked Percent. The Stacked Count layout displays the numerical variable on the chart as totals for both the category and subcategory, with the length of the bar and segments inside the bar representing the amount of the numerical variable. The Stacked Percent layout displays all categories as the same size, representing a range from 0 to 100%. The subcategories are all displayed as proportions of the bars. The Style tab can also be used to change the outline color.
The value of each bar can be symbolized as a count of features in each category on the y-axis, or as a number or rate/ratio field. If a field is used, the bar values can be calculated as a sum, minimum, maximum, average, percentile, or median of values from the field for each category.
Median and percentile are not available for remote feature layers.
The subgroup can be removed to change the stacked bar chart to a bar chart.
Use the Chart statistics button to display the mean, median, upper quartile, lower quartile, or a custom value.
Use the Sort button to sort the categorical data in either ascending or descending order by the numeric variable or alphabetically.
When you create a stacked bar chart, the result dataset with the string and number fields used to create the chart is added to the data pane. The result dataset can be used to find answers with nonspatial analysis using the Action button .