Saturday, November 4, 2017

Creating Scatter Plot with Radial References

I was given a hand drawn whiteboard shot. Someone needs a scatter plot with radial references just like that. It made sense to me immediately. In a scatter plot, horizontal and vertical references seem no more enough. I would love to see such a chart in Tableau.
I know what is needed: polygon in dual axis with scatter plot. But I never did it before. It still took some research and optimizations to make it work. Bora Beran's blog is a great source of inspiration to me in my research.

1.Data preparation
To add radial references, we need to prepare your data first. That is, add a few rows to the data set. This can been done by Union in SQL.

Assuming we want 3 reference arcs, then we need 6 rows or 2 rows per arc. The 2 rows designate both start and end points for each polygon-based arc. Here we will use 102 points for each polygon. 102 points seem enough to make the arcs look smooth. More points can be added if necessary.

Note that there is a Reference column in the table which labels rows for arcs and data.
2.Drawing Arcs
This will use the data densification technique native to Tableau. The main steps are:
- create bins based on [Path] with step size = 1. This will create potentially102 bins.
- drag Path bin to Rows
- right click Path bin on Rows and select Show Missing Values.
- select Polygon as data mark
- drag Path bin to the Path shelf in Polygon data marks.

Then create coordinates for the arcs.
- X Arc and similar for Y Arc
- Drag X Arc to Columns and Y Arc to Rows. Both are table calculations. Make sure they are calculated along the Path bin dimension. We should see the arcs.

3.Creating the Scatter Plot
Use X and Y and the plot is easy. Dot Size can be any measure that will show in the size of each dot.

4.Dual axis both Arcs and Scatter Plot
We need to have a single horizontal axis variable for both charts. Here is X All:

  • IF ATTR( [Reference] )='Data' THEN ATTR( [X] )
  • ELSE [X Arc]
  • END
Note that we have to move X to the Details shelf in the scatter plot's marks card. This is necessary to display all the dots. Make sure X is a dimension by right clicking it. Also Y has to be a decimal type in order to sync with the other axis.

Voila, it's basically done.
Click the image to go to the interactive version.

5.Parametrization
Note that we use one parameter for each arc's radius. The radius can be changed to any value.

The number of points for an arc can also be a parameter. Here we just use a fixed number: 102.

There seems that the number of arcs can not be parametrized. We need to define the number of arcs a priori.

6.Generalization 
We assumed that the scales of both X and Y axis are the same. In some cases, this may not be true. Then an arc may not be a quarter of a circle. Instead, it is part of an ellipse. If that's the case, we have to calculate the coordinates differently.

7.Use cases
Forrester Research has been using scatter plots with radial references for years. Check them out: https://goo.gl/oJZ6p7

11 comments:

  1. This is really an interesting post. Could you also explain some use cases for this type of chart.When I first saw this ,I started considering these arc's as some sort of radial reference line like first quadrant 25%, 2nd Quadrant 50 % etc which may help user in setting some sort of Goal. Please do correct me if my understanding is wrong .

    ReplyDelete
  2. Per your question, I added an example in the above article.

    ReplyDelete
  3. I can only get to step 2 and the shaded arcs are not visible. I am using 10.2 and can not open the sample file. Should Y arc be using "Sin" vs "Cos"?

    ReplyDelete
    Replies
    1. Y should use SIN and X should use COS. You can download Tableau Public to open it.

      Delete
    2. I'd like to post an article(on my website) that lays out the steps to create this shading in more detail. I would give credit to you and link to your page. Do you have any issues with this? My website is PalmerAnalytics.com.

      Delete
    3. There should be no problem. Go ahead. Feel free to leave a link here when you are done.

      Delete
    4. Here's the link. Let me know what you think.
      http://palmeranalytics.com/articles/tableau-concentric-arc-shading

      Delete
  4. Hi, please can you explain where did the measure "Arc radius" come from - the one you are using in the X Arc calculation? Am I am missing something?

    ReplyDelete
    Replies
    1. X Arc is the x coordinate for the arc. Download the workbook and you will see the details. Sorry for late reply.

      Delete
  5. hi. where i can download the workbook used for data source?

    ReplyDelete