Moving Quadrants on a Scatter Plot

With scatter plots its always useful to see trends, however, sometimes we want to see how the points on the scatter plot relate to other scatter plots. Do to this the best way is using quadrants. In this blog we can see how to make these quadrants but then also how we can make these quadrants dynamic.

To start off we would simply create a [Sales] and [Profit] Scatter Plot in tableau, and set [Product Name] to detail.

After this we want to create 2 parameters. 1 for Sales and 1 for Profit.

We then want to put these parameters as reference lines on the scatter plot.

We do this by going to the analytics pane and then dragging the reference line onto the scatter plot.

But we want to make these reference lines move so that when you click on a dot that will be the centre of the lines.

To do this we need to add parameter actions to these lines. To do this we need to click worksheet→Actions→Add action→Change Parameter.

After doing this for both profit and Sales the lines will move based on which point on the scatter plot you click.

This is still hard to break down especially if we were to click that big cluster at the bottom. So we want to colour the points depending on the quadrant they are in. So, we need to write a calculated field, and drag it onto the colour mark card.

The code for this is:

If SUM([Sales])>[Sales Parameter] AND SUM([Profit])>[Profit Parameter] THEN "YY"

ELSEIF SUM([Sales])>[Sales Parameter] AND SUM([Profit])<[Profit Parameter] THEN "YN"

ELSEIF SUM([Sales])<[Sales Parameter] AND SUM([Profit])>[Profit Parameter] THEN "NY"

ELSEIF SUM([Sales])<[Sales Parameter] AND SUM([Profit])<[Profit Parameter] THEN "NN"

ELSE "Selected"

END

This will split the scatter plot to look like this:

This logic will work for any scatter plot so hopefully you can use this in the future for whatever use case you need.

Author:
Alfie King
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab