Creating a 4 Quadrant Square Chart




I recently saw a great chart from Pew Research via Steve Wexler on Twitter.


This shows a 2X2 Matrix of survey data in 4 quadrants of favor/oppose. This is a really great chart, and it can 100% be created in Tableau.

Ramon Martinez quickly showed how you can use Polygons to create it.


After looking at this for a minute, I realized that there are bar chart features in Tableau that would allow us to create this chart without data-prep.

Steps

When we look at the chart, there are things we can immediately take away, for one, there are 4 quadrants around a 0,0 center point. From this point, there are squares sized by area around it.

While we can't use the "Square" shape mark to do this, we can use Bar Charts to simulate a Square.

The key here is to use "Fixed" size for Bar Chart. We can do this by setting up a Continuous X Axis that will let us place the Bars according to a specific value (in this case Sales).

I am using a conditional calc to control where on the X Axis the SQRT of Sales will fall. For the right side of my quadrant, I want the SQRT of sales to be positive, for the left side I want them to be negative.

CASE MIN([Region])
WHEN 'Central' THEN -SQRT(SUM([Sales]))
WHEN 'East' THEN SQRT(SUM([Sales]))
WHEN 'West' THEN -SQRT(SUM([Sales]))
ELSE SQRT(SUM([Sales]))
END

Using the Circle Mark, you can see how this places the values.


Now that we have the X Axis, the next step is to get the Height. We are going to use a similar conditional calc to get this. For our Top 2 Quadrants, we want to get the Positive value for the SQRT of Sales, and the Bottom Quadrants we want to the Negative value for the SQRT of Sales.

CASE MIN([Region])
WHEN 'Central' THEN SQRT(SUM([Sales]))
WHEN 'East' THEN SQRT(SUM([Sales]))
ELSE -SQRT(SUM([Sales]))
END

Placing that on the Rows Shelf, we can start to see the shape of the chart.


The next step is to change the Chart Type to Bar, which will look a bit funny....


One of the great features to come out of Tableau in the version 10 series is the "Fixed" size option for Bar Charts. While the original intention for them was to create marimekko chart, but we can use the feature laterally to do other things (I do this alot). This let's use define a Width for the Bar Charts according to a measure. Since our X/Columns shelf is using a Continuous Dimension (which we got using LoDs), we take the opposite value of it an place it on the Size Mark and set it to Fixed.



Alternative Approach:

Quickly after writing this, I realized there was another option. Instead of using the Width Calc on the Columns Shelf, and then using - Width on the Size Mark, we can use MIN(0) on the Column Shelf and Width on the Size Mark. By turning Stack Marks Off, we can get the same result.



And that's it! Hope this helps.
Previous
Next Post »
2 Comment
avatar

Rody, this is so cool.. thanks for sharing... I will try this for sure

Balas