[R] par(new = TRUE) - overplotting
Antje
niederlein-rstat at yahoo.de
Wed Oct 8 16:37:33 CEST 2008
Hi everybody,
I want to create some boxplots (as png) within an lapply method. To get nice
gridlines behind the boxplot, I plotted it twice and therefore I set par(new=TRUE).
This works nicely for the first plot but the second does plot on the first plot
too and creates a mess...
How can I force to start with a blank plot again???
lapply(c(1,2), FUN=function(i) {
png(filename = "test.png", width = 450, height = 600)
gridlines <- seq(0.1,2.0,0.1)
par(mar=c(12, 4, 5, 2))
bpars <- list(yaxt = "n", las = 2 )
boxplot(mydata[i], pars= bpars )
abline(h = gridlines, col="lightgray", lty=2)
abline(h = 1, col="red", lwd=3)
par(new=TRUE)
boxplot(mydata[i], pars= bpars, main = "title")
dev.off()
})
Ciao,
Antje
More information about the R-help
mailing list