Have you ever seen a chart like this in a presentation or news article? It is an effective way to show a binary distribution.
Introducing guest author, Thom Siragusa. Thom is Manager, Solutions Consultants on the Spotfire Partner Team. He is an advocate for data analytics and big data solutions. He organizes and leads Spotfire “bootcamp” sessions for new technology partners all across the globe. Follow his tweets at @thomsir.
In this post, he demonstrates a creative way to configure a bar chart in order to create a pyramid visualization.
It has various names, including “Christmas Tree” or “Pyramid Graph” or “Population Pyramid” or “Paired Bar Graph” or “Two-way Histogram”. Here is how to do it in Spotfire, including two tricks to achieve the result we want.
1. Create a bar chart with horizontal bars.
2. Select a column for your Value axis, such as Count() or Sales. In this example, we’ll use Groceries which is the dollar amount of Grocery sales.
3. For the ColorBy, select the column with two values, such as Gender.
4. Now, we need to have one value for Gender appear on the left side of ‘0’. To do that, let’s edit the custom expression for the Value. In my case, the current expression Sum([Groceries]) needs to be modified as to whether it is grocery sales for Men or Women. So the new custom expression is:
Sum(If([Gender]="Male",[Groceries] * -1,[Groceries]))
Essentially, we are making the grocery sales negative when purchased by men.
5. Here is the interim result:
6. We can see that the Value axis shows negative numbers, as would be expected. We can solve the negative label issue by hiding the scale and showing the relative distribution (more women bought groceries; no young men bought groceries) or we can use our second trick to format the value to not show a negative sign.
Spotfire is highly customizable. You can select from many formatting types or customize your own. The help system shows you how. Open the Help and in the index find Format String.
For a numeric, we can specify what symbol(s) to use for negative values, and so in this case we won’t use any symbol at all.
For the visualization, go to Properties / Formatting / Value Axis / Custom and set the custom format string.
In my example, I want a short number format (K for thousands) and no sign symbol for negative values, so I used $#0,K;$0#,K.
7. Here is the final result. For further emphasis, I added a white vertical line with value of 0.
8. For multiple values to Color By, I suggest using grades of the same color.