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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to