Hi R-users, I inted to make multiple plots using for loop. The question is how can I adjust the left hand side margin of the plot according to the names.arg argument in barplot2. In every plot I have different annotations in the y axis and they vary in length. Now when I have fixed margins
opar <- par(mar=c(3,15,0,2)... I get the same margins in all of the plots. That leaves lots of white space in plots where the annotations are short. Here is the code I'm using: library(gplots) opar <- par(mar=c(3,15,0,2), bg="white", cex=1, oma = c(0, 0, 2, 0), mgp=c(3,0.5,0)) for (i in names(spl)) { .order <- order(spl[[i]]$x) barplot2(spl[[i]]$x[.order], names.arg=as.character(spl[[i]]$os[.order]), horiz=TRUE, las=1, cex.names=0.7, cex.main=0.9, cex.axis=0.7, xlim=c(0, max(spl[[i]]$x)+10), col=as.character(spl[[i]][1,7]), plot.grid = TRUE, ) box() mtext(paste(paste(as.character(spl[[i]][1,2]), ":", sep=""), "texthere", "(texthere)", as.character(spl[[i]][1,3])), outer=T, line = 0.5, cex=1.1) mtext("texthere", side=1, line=1.5, adj=0.5) dev.copy(png, filename=paste(i, ".png", sep=""), height=400, width=480) dev.off() } Thanks in advance Lauri ______________________________________________ R-help@stat.math.ethz.ch 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.