How to add a 45°, 30° and 60° trend line in Tableau

Whilst doing some reading on network analysis (viz coming soon), I found this great blog by Martin Grandjean, a data analyst in the Digital Humanities community.

Within the post their are a number of stunning visuals, but the one that got my most attention was the scatter plot with trend lines at 45°s , 15°s, 30°s, 60°s and 75°s.

2016-11-24_17-52-29.png

The reference lines at 4x, 2x and 0x make it easy to identify the groups of ‘unpopular’ and ‘popular’ in the digital humanities twittersphere.

So of course, being predominantly a Tableau user, I  wanted to make this in Tableau…so I did and here’s how.


Step 1. Build your scatter plot.

Step 2. Create a dual axis by dragging the measure used on rows onto columns as well (you can instead drag the measure you used on columns onto rows). You will see that your points on your second axis create a 45° trend line, because x=x or y=y.

2016-11-24_18-35-08.png

Step 3. Build out a calculated field for each angle you wish. For example in my use case I want additional trend lines at 30° and 60°.

As a result I will create 2 calculated fields.

2016-11-24_18-42-20

2016-11-24_18-43-40

Step 4. Create a shared axis on your secondary axis. In order to do this drag your measures one by one over your second axis until two rulers appear, you can then release your mouse and you will create a shared axis chart.

sad.png

Step 5. It is important to note that one of the features of a trend line in Tableau is that you can create one for each dimension that exists on the colour shelf. So our next step is to drag measure names from the shape shelf (in most cases when you build a dual axis chart it will automatically place your values on shape), onto the colour shelf.

Step 6. Navigate to the analytics pane, and drag trend line onto the ‘linear, measure values’ area.

sadsd.png

asdsd.png

Step 7. Use the size shelf on your secondary axis to make your marks and small as possible, then use the colour shelf to make them transparent, and finally, delete your tooltip.

Be sure to change the colour of your lines using the colour legend if you wish.

2016-11-24_18-56-10.png

Step 8. Dual axis your chart.

It is important to note that you cannot sychronise your dual axis chart when you are using one (or more) as a shared axis so you will have to fix your axis.

2016-11-24_18-58-31.png

Ben

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s