Scatter Plot Matrices

Sameer Mathur

Scatter Plot Matrices using pairs (1)

pairs(~ mpg + disp + drat + wt, data=mtcars, 
      main="Basic Scatterplot Matrix")

All the variables on the right of ~ are included in the plot. Here we can see the bivariate relationship among all the variables specified.

Scatter Plot Matrices using pairs (2)

plot of chunk unnamed-chunk-2

car::scatterplotMatrix (1)

The scatterplotMatrix() function in the car package can also produce scatter plot matrices and can optionally do the following:

  • Include linear and loess fit lines.
  • Place box plot, densities, or histograms in the principal diagonal.
  • Add rug plots in the margins of the cells.


Note: LOWESS (Locally Weighted Scatterplot Smoothing), sometimes called LOESS (locally weighted smoothing), is a popular tool used in regression analysis that creates a smooth line through a scatter plot to help you to see relationship between variables.

car::scatterplotMatrix (2)

library(car)
scatterplotMatrix(~ mpg + disp + drat + wt, data=mtcars,
                  main="car::scatterplotMatrix")

Scatter plot matrix created with the scatterplotMatrix() function. The graph includes kernel density curve and rug plots in the principal diagonal and linear and loess fit lines.

  • The regression line (in green)
  • The non-parametric regression smooth (LOWESS) (solid line, red)

car::scatterplotMatrix (3)

plot of chunk unnamed-chunk-4

car::scatterplotMatrix (4)

plot of chunk unnamed-chunk-5