A correlation plot visualizes the relationship between two continuous numeric variables. Its points reveal whether variables move together, move in opposite directions, or show little meaningful association. section 1.2.1
Build and interpret a correlation plot in R by following these steps:
- Compute the association with base R's cor() function, then map one numeric variable to each axis in ggplot2. section 4.5.3
- Add geom_point() for the observations and geom_smooth(method = lm, se = FALSE) for a linear regression line without its default confidence interval. section 4.5.3 section 14.4.1
- Read the coefficient and point pattern together: positive values indicate shared movement, negative values indicate opposite movement, and values near neutrality indicate weak association. section 1.2.1 section 4.5.3
NBA salaries and win shares
For free agents, cor(free_agents$annual_salary, free_agents$win_shares) returns about 0.76. Plot annual_salary against win_shares with geom_point(), label the coefficient, and add a regression line; the result shows a strong positive association. A second example compares points allowed and wins (-0.58) with points scored and wins (0.53) using side-by-side plots. section 4.5.3 section 14.4.1
Use the automobile visualization figure to compare a correlation plot with a facet plot, bar chart, and histogram. section 1.2.1
