Scatter plots provide an easy way to visualize relationships between numerical variables. In Tableau, you create a scatter plot by placing at least one measure on the Columns shelf and at least one measure on the Rows shelf. If these shelves contain both dimensions and measures, Tableau automatically places the measures as the innermost fields, which means that measures are always to the right of any dimensions you have also placed on these shelves. The word "innermost" in this case refers to the table structure.
|Creates Simple Scatter Plot||Creates Matrix of Scatter Plots|
The following exercise walks you through using scatter plots and trend lines to compare sales to profit:
- Open the Sample - Superstore - English (Extract) data source, which is included with Tableau Desktop.
Drag the Profit measure to Columns.
The measure is automatically aggregated as a sum and a horizontal axis is created.
Drag the Sales measure to Rows.
The measure is automatically aggregated as a sum and a vertical axis is created.
Measures contain continuous numerical data. When you plot one number against another, you are comparing two numbers; the resulting chart is analogous to a Cartesian chart, with x and y coordinates.
What you have at this point is the most basic kind of scatter plot: a one-mark scatter plot:
Drag the Department dimension to Color on the Marks card.
This separates the data into three marks—one for each dimension member—and encodes the marks using color.
Drag the Region dimension to Detail on the Marks card.
Now there are many more marks in the view. The number of marks is equal to the number of distinct country/regions in the data source multiplied by the number of departments. (If you're curious, see what would have happened if you'd dropped the Region dimension on Shape instead of Detail.)
Right-click in the view and choose Trend Lines >Show Trend Lines to add trend lines.
A trend line can provide a statistical definition of the relationship between two numerical values. To add trend lines to a view, both axes must contain a field that can be interpreted as a number—by definition, that is always the case with a scatter plot.
Tableau adds three linear trend lines—one for each color that you are using to distinguish the three departments:
Hover the cursor over the trend lines to see statistical information about the model that was used to create the line:
For more information, see Assessing Trend Line Significance. You can also customize the trend line to use a different model type or to include confidence bands. See Adding Trend Lines.
See AlsoExample – Scatter Plots and Aggregation