Create a matrix of scatterplots (pairs() equivalent) in ggplot2

You might want to try plotmatrix:

  library(ggplot2)
  data(mtcars)
  plotmatrix(mtcars[,1:3])

to me mpg (first column in mtcars) should not be a factor. I haven’t checked it, but there’s no reason why it should be one. However I get a scatter plot 🙂


Note: For future reference, the plotmatrix() function has been replaced by the ggpairs() function from the GGally package as @naught101 suggests in another response below to this question.

Leave a Comment