I'm using some of the ideas from here. I would like to draw a box on top of the lattice bwplot
.
I would like to combine the solution provided with boxplot on lattice bwplot. Ideal pure lattice bwplot solution.
Sample data:
rdata <- data.frame(y=rnorm(1000,2,2),v1=rnorm(1000,1,1),v2=rnorm(1000,3,3),
v3=rnorm(1000,4,4),v4=rnorm(1000,5,5),v5=rnorm(1000,3,3))
I would like to plot a box on top of bwplot
, here is a boxplot solution:
p <- par(mfrow=c(3,2))
for(i in 1:6){
boxplot(rdata[,i],horizontal=TRUE,axes=FALSE)
rect(min(rdata[,i]),1.5,quantile(rdata[,i],0.25),1.4,col="red")
rect(quantile(rdata[,i],0.25),1.5,quantile(rdata[,i],0.60),1.4,col="green")
rect(quantile(rdata[,i],0.60),1.4,max(rdata[,i]),1.5,col="yellow")
}
par(p)
How to do the same within lattice bwplot
? It is possible at all? Thanks!
Just to give some starting point for the bwplot:
library(lattice)
library(gridExtra)
plot1 <- lapply(1:2, function(i) {bwplot(~rdata[,i],rdata)})
plot2 <- lapply(1:3, function(i) {bwplot(~rdata[,i],rdata)})
plot3 <- lapply(1:4, function(i) {bwplot(~rdata[,i],rdata)})
print(do.call(grid.arrange, c(plot1,plot2,plot3)))