This is the second part of a three-part series on Tableau Playbook - Diverging Bar Chart. In the first part, we delved into basic concepts and the butterfly chart. Check it out in case you missed it.
In this guide (Part 2), we will focus on another diverging bar chart: the Standalone Diverging Bar Chart. We will learn it in the following steps:
Here are two examples using standalone diverging bar charts from the New York Times and JoeyCloud.
The left chart shows positive and negative factors that affect lifespan. The right diverging histogram shows the frequency of piano keys.
A standalone diverging bar chart contains one dimension and one measure, or only one measure in a diverging histogram. It highlights the double-edge of a dimension, such as the positive and negative factors in the left example.
For the U.S. Birth Rates dataset, we will display the time trends of the birth rates from a specific age group. In order to highlight the difference between growth and reduction, we use the average birth rate as the baseline.
Let's draw a basic standalone diverging bar chart step by step:
Create bins to decrease the "Year" dimension: right-click "Year" dimension -> choose Create - Bins... -> edit Size of bins to 2 in the pop-up dialog -> drag it into Column Shelf.
[Birth Rate] - {FIXED [Age Start] : AVG([Birth Rate])}
-> drag it into *Rows Shelf.Create a filter for age group:
In the last step, let's polish this chart:
A standard standalone diverging bar chart is completed.
Here is a defect in the basic version. In order to make bars divided by zero-axis, we used a calculated field to compute the difference from the average, but axis values become relative. We will solve this problem in the next section.
To optimize the above chart, we will keep the absolute values and use a non-zero axis as the baseline, with the help of Gantt Bar.
Create a Calculated Field "Birth Rate Diff 2" for Gantt Bar: right-click in the blank of Data Pane -> choose Create Calculated Field... -> input the formula ([Birth Rate]-{FIXED [Age Start] : AVG([Birth Rate])})*-1
Set the Size of Gantt Bar:
Change the Legend type to Single Value (list). Thus, we can switch the age group in the Legend to explore more information.
From the above final chart, we can see this diverging bar chart is divided by a non-zero axis and displays the absolute values.
To make the chart more readable, we can clean both dimension and measure labels and make them closer to the bar. This section is inspired by TableauTimothy. Let's Duplicate the basic chart and reform on it:
Drag the "PlaceHolder" into Columns Shelf.
Create two Calculated Fields:
"Positive Year Label": IF [Birth Rate Diff] > 0 THEN [Year] END
"Negative Year Label": IF [Birth Rate Diff] < 0 THEN [Year] END
Here, we use the dual axis technique to display dimension labels on both sides:
-
in the head): -AVG([Birth Rate Diff])
Dimension labels have been placed on both sides successfully. Now, we will work on the measure labels because a mark can only support one alignment. So, we need Reference Lines to display measure labels on the opposite side:
IF AVG([Birth Rate Diff]) > 0 THEN AVG([Birth Rate Diff]) END
"Negative Birth Rate Label": IF AVG([Birth Rate Diff]) < 0 THEN AVG([Birth Rate Diff]) END
With the help of dual axis and reference line, we customize both dimension and measure labels on a diverging bar chart and make it cleaner.
With the help of a standalone diverging bar chart, we can see the time trends more intuitively.
For the age group of 30-34, there are two positive regions (green bars). One is from 1942-1964, the other is from 2000-2013. Let's infer the possible reasons. The first mountain is caused by World War II. The United States advocated more births for recovery and development. The reason for the second mountain is that modern people tend to postpone their marriage and childbirth.
When you use a standalone diverging bar chart and make a relative comparison, be careful with the meaning of the two sides because the misuse of a diverging bar may cause misleading statistics. For more information you can refer to Mona Lebied's blog.
In this part, we have learned a standalone diverging bar chart. First, we learned the standard process to create a standalone diverging bar chart, and then we dug into the situation which needs a non-zero axis as the baseline.
In the third part of this series, we will focus on Diverging Stacked Bar Chart and compare with other bar charts.
You can download this example workbook Bar Chart and Variations from Tableau Public.
In conclusion, I have drawn a mind map to help you organize and review the knowledge in this guide.
I hope you have enjoyed it. If you have any questions, you’re welcome to contact me [email protected].