Author avatar

Recnac

Tableau Playbook - Scatter Plot

Recnac

  • Mar 2, 2020
  • 14 Min read
  • 846 Views
  • Mar 2, 2020
  • 14 Min read
  • 846 Views
Data
Tableau

Introduction

Tableau is the most popular interactive data visualization tool nowadays. It provides a wide variety of charts to explore your data easily and effectively. This series of guides—Tableau Playbook—will introduce all kinds of common charts in Tableau. And this guide will focus on the scatter plot.

In this guide, we will learn about the scatter plot in the following steps:

  1. We will start with an example chart to introduce the concept and characteristics of the scatter plot.
  2. By analyzing real-life datasets, we will learn to build a scatter plot step by step. We will then optimize and polish the chart with advanced features.

Getting Started

Example

Here is a scatter plot example of the 2018 Developer Survey results from Stack Overflow. It shows the relationship between salary and experience by programming languages.

example chart - scatter plot

We can mine a lot of information from this scatter plot:

  1. As a whole, we use the trend line to fit the linear relationship between experience and salary.
  2. From a horizontal perspective, we can compare the age distribution of the developers who work in various languages. From a vertical perspective, we can compare the median salary distribution for developers who work in each language.
  3. Additional visual elements, such as size and color, allow a scatter plot is able to convey more information. In this example, the size of the circles intuitively expresses the popularity of language.
  4. With the help of the scatter plot, we can dig out useful information. For example, developers in Go, Clojure, and F# are being paid more even given how much experience they have. Developers using languages below the line, like PHP and Visual Basic 6, however, are paid less, even given years of experience.

Concept and Characteristics

According to the wikipedia entry about the scatter plot:

A scatter plot is a type of plot using Cartesian coordinates to display values for typically two variables for a set of data. If the points are coded (color/shape/size), one additional variable can be displayed.

Scatter plots are commonly used in statistical analysis. They are an extremely effective way to compare multiple measures for a dimension with many distinct values. The basic case is to compare two measures with x and y axes. More measures can be added by Tableau's visual elements, such as size and color.

It is important to understand the strengths and weaknesses of a scatter plot if you are going to use them.

Scatter plots have the following strengths:

  • Scalability - can hold a large number of points: Scatter plots give us an option to display a lot of data in a small area with relatively low confusion rates.
  • Analyze correlation: A typical use of a scatter plot is to determine whether two measures are correlated. Tableau provides statistical variables such as the P-value and R-squared. But it's important to note that we need to treat correlation objectively. When two variables are correlated, it does not mean that one variable caused the other.
  • Observe data intuitively: In a scatter plot, you can visually observe outliers, data ranges, or specified areas. What's more, with the interactive operation provided by Tableau, we can further analyze these points in detail.

The biggest disadvantage of a scatter plot is the possibility of over plotting. While it is able to hold plenty of data, over plotting may become a problem when a scatter plot is dense. We can reduce this visual discomfort by adjusting the opacity or highlighting.

Dataset

In this guide, we'll use the dataset Boston Housing from Kaggle Dataset. Thanks to the U.S. Census Service and Kaggle for this dataset. The data was collected in 1978, and each of the 506 entries represents aggregated data about 14 features for homes from various suburbs in Boston, Massachusetts.

In this guide, we will analyze how the following factors affect house price:

  • MEDV: Median value of owner-occupied homes in $1000's
  • RM: average number of rooms per dwelling
  • CRIM: per capita crime rate by town
  • LSTAT: % lower status of the population

Basic Process

Let's start by creating a basic scatter plot step by step.

  1. Before drawing, we need to do some data preprocessing with the help of external tools such as Excel. To display each row as a point, we need to add ID to identify. The easiest way is to add the ID column in Excel. At present, it is hard to create unique identifiers in Tableau. If you insist on that, please refer to this post.
  1. We can generate a basic chart automatically by using Show Me. This is the easiest way to build a scatter plot. Click on Show Me and you will see these instructions:

    For scatter plots, try 0 or more Dimensions, 2 to 4 Measures.

In this example, we need two measures, RM and MEDV. Hold down the Control key (Command key on Mac) while clicking to multiple select RM and MEDV, then choose scatter plots in Show Me.

scatter plot - basic process 1

  1. Now we notice there is only one point in the chart. That is because all the records are aggregated together. Here we can split the data by ID, which we created before.

    1. Convert ID into Dimension.
    2. Drag ID into Marks - Detail.
    3. Switch to Entire View for a nicer visualization.
  1. On the top of the scatter plot, sixteen data points have a 1MEDV1 value of 50.0. They are outliers that have been clamped by the upper bound. For a more accurate analysis, we should remove these outliers. Multi-select them and click Exclude in the pop-up dialog. Tableau will exclude them in the Filters.
  1. For a more attractive chart, edit visual elements such as shape and color:

    1. Expand the Shape card in Marks and replace the empty circle with the solid circle or any other shape that makes sense for your readers.
    2. To reduce the impact of the overlay, expand the Color card in Marks and slide the Opacity to semitransparent.

scatter plot - basic process 2

  1. Add a trend line to identify the correlation between RM and MEDV.

    1. Right-click on the chart and choose Trend Lines -> Show Trend Lines.
    2. Right-click on the trend line and click Edit Trend Lines...
    3. Choose Linear as the Model type.
    4. Check Show Confidence Bands.
  1. In the last step, let's polish this chart:

    scatter plot - basic process 3

    1. Edit title to "Relationship between Room Number and House Price".
    2. Rename the x-axis as "Room Number" and y-axis as "House Price".

Analysis:

In this basic scatter plot, we analyze the correlation between number of rooms and house price. We simulate the relationship by the linear model. From the statistical variables provided by Tableau, we can see that P-value is less than 0.001 and R-Squared is 0.471. This indicates their linear correlation is relatively high.

When focusing on the points, we can dig out some other information. We find out the average number of rooms is between 5.5 and 6.8 and house price is between 15,000 and 25,000. We can also clearly distinguish the outliers and further analyze the detail information of them.

Advanced Features

In this section, we will add more advanced features to enhance the scatter plot.

  1. First, let's build a scatter plot as we did previously.

    1. This time we'll build it manually. Drag LSTAT into Columns Shelf and MEDV into Rows Shelf.
    2. Drag ID into Marks - Details.
    3. Right-click and choose Hide Indicator for nulls values.
    4. Multi-select the top outliers and click Exclude in the pop-up dialog.
    5. Switch to Entire View for a better view.

scatter plot - advanced features 1

  1. Add more visual elements to convey information. Here we show measure CRIM by size.

    1. Drag CRIM into Marks - Size.
    2. Adjust size by expanding the Size card or the size legend on the right side.
  1. The clustering technique is useful to analyze the characteristics of a scatter plot. Tableau has built-in clustering algorithms, such as k-mean. Let's try out Tableau's clustering capabilities to look for the common properties of points.

scatter plot - advanced features 2

  1. Switch to the Analytics pane. Drag Cluster into the view and drop it on the Create Clusters box that appears.
  2. We can see it is calculated by the three measures we created before. We remove CRIM and see what's going on with only two axis variables.

    Notice Tableau found four clusters. Each cluster reflects a potential class of houses from different prices and LSTAT ranges. We can dig more information from these clusters, but we will stop here and focus on the scatter plot.

  1. Let's add another measure RM as color.

    1. Drag RM into Marks - Color.
    2. The default color configuration is not good enough. Let's make it better. Click the inverted triangle in color legend, then choose Edit Colors...
    3. To distinguish the color more clearly, we change the single color to diverging colors. Choose Red-Green-Gold Diverging in Palette.
    4. In order to group the points by number of rooms, we check Stepped Color and set Steps to 5.

scatter plot - advanced features 3

  1. Add more quantitative indicators to the scatter plot:

    1. Switch to the Analytics tab, and drag Average Line into Table - Cell of SUM(LSTAT) and SUM(MEDV). Left click on them and change the type to Median.
    2. Add a trend line as we did before. The only difference is that this time, we simulate the model type as Logarithmic.
  1. Put on the finishing touches:

    scatter plot - advanced features 4

  1. Edit title to "Factors which affect House Price in Boston".
  2. Rename the x-axis "Lower Status of Population" and y-axis "House Price".
  3. Rename the size legend "Crime Rate" and color legend "Room Number".
  4. If you think these grid lines are too distracting, you can remove them to make the chart cleaner: navigate to Format -> Lines... and set Grid Lines to None in Lines.

Analysis:

With these advanced features, the scatter plot becomes more powerful. With the color elements, we can see that generally the more rooms a house has, the higher the house price will be. With the size elements, we find out that the higher the crime rate is, the lower the house price will be.

Conclusion

In this guide, we have learned about one of the standard charts in Tableau: the scatter plot.

First, we introduced the concept and characteristics of a scatter plot. And then we learned the basic process to create a scatter plot. Finally, we enhanced the scatter plot with clustering, size, color, and quantitative indicators.

You can download an example workbook of Standard Charts from Tableau Public.

In conclusion, I have drawn a mind map to help you organize and review the knowledge in this guide.

scatter plot - mind map

I hope you enjoyed it. If you have any questions, you're welcome to contact me at [email protected]

More Information

If you want to dive deeper into this topic, there are many professional Tableau Training Classes on Pluralsight, such as Tableau Desktop Playbook: Building Common Chart Types.

Here is a complete list of guides in this series about common Tableau charts:

CategoriesGuides and Links
Bar ChartBar Chart, Stacked Bar Chart, Side-by-side Bar Chart, Histogram, Diverging Bar Chart
Text TableText Table, Highlight Table, Heat Map, Dot Plot
Line ChartLine Chart, Dual Axis Line Chart, Area Chart, Sparklines, Step Lines and Jump Lines
Standard ChartPie Chart, Tree Map, Scatter Plot, Box and Whisker Plot, Gannt Chart, Bullet Chart, Bubble Chart, Map
Derived ChartFunnel Chart, Waterfall Chart, Waffle Chart, Slope Chart, Bump Chart, Sankey Chart, Radar Chart, Connected Scatter Plot, Time Series, Word Cloud
Composite ChartLollipop Chart, Dumbbell Chart, Pareto Chart, Donut Chart, Radial Chart, Burn Down Chart

2