I feel like
plotmatrix is a much-neglected ggplot2 function (it’s not even on the ggplot2 webpage). It’s the equivalent of
plot(dataframe) from the core graphics package, with the added bonus of a kernel density plot along the diagonal.
The one thing that seems to be missing is the ability to color the points by some factor. I modified the plotmatrix function to enable this. Here’s an example.
My data looks something like this:
> head(data) a b c d level 1 1 2 5 2 FALSE 2 1 21 2 1 FALSE 3 26 1 NA 1 FALSE 4 8 45 13 12 FALSE 5 3 25 4 4 FALSE 6 4 NA 1 2 FALSE
And when I plot it using
plotmatrix I get the following:
None of the aesthetic mappings actually make it to the plot. I changed it so that the aesthetics get passed to the points only:
plotmatrix2(data, mapping=aes(colour=data$level, shape=data$level))
And here’s the code: