I just came a cross this nice code that makes this scatter matrix plot:
And wanted to implement it to a likret scale variables (integers of 1 to 5) by making the dot's sizes/colors (in the lower triangle) differ according to how many options of that type occurs (like the effect the jitter might have given me).
Any idea on how to do this on the base plotting mechanism ?
Update:
I made the following function, but don't know how to have the scale of the dots always be "good", what do you think ?
panel.smooth2 <- function (x, y, col = par("col"), bg = NA, pch = par("pch"),
cex = 1, col.smooth = "red", span = 2/3, iter = 3, ...)
{
require(reshape)
z <- merge(data.frame(x,y), melt(table(x ,y)),sort =F)$value
z <- z/ (4*max(z))
symbols( x, y, circles = z,#rep(0.1, length(x)), #sample(1:2, length(x), replace = T) ,
inches=F, bg="blue", fg = bg, add = T)
# points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
lines(stats::lowess(x[ok], y[ok], f = span, iter = iter),
col = col.smooth, ...)
}
a1 <- sample(1:5, 100, replace = T)
a2 <- sample(1:5, 100, replace = T)
a3 <- sample(1:5, 100, replace = T)
aa <- data.frame(a1,a2,a3)
pairs(aa , lower.panel=panel.smooth2)