You can do this kind of thing with lattice
cloud
plots, using panel.3dpolygon
from latticeExtra
.
library(latticeExtra)
# generating random data
d <- data.frame(x=rep(1:40, 7), y=rep(1:7, each=40),
z=c(sapply(1:7, function(x) runif(40, 10*x, 10*x+20))))
# define the panel function
f <- function(x, y, z, groups, subscripts, ...) {
colorz <- c('#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3',
'#fdb462', '#b3de69')
sapply(sort(unique(groups), decreasing=TRUE), function(i) {
zz <- z[subscripts][groups==i]
yy <- y[subscripts][groups==i]
xx <- x[subscripts][groups==i]
panel.3dpolygon(c(xx, rev(xx)), c(yy, yy),
c(zz, rep(-0.5, length(zz))),
col=colorz[i], ...)
})
}
# plot
cloud(z~x+y, d, groups=y, panel.3d.cloud=f, scales=list(arrows=FALSE))
I'm sure I don't need to loop over groups
in the panel function, but I always forget the correct incantation for subscripts
and groups
to work as intended.
As others have mentioned in comments, this type of plot might look snazzy, but can obscure data.
