Hi all, When making a bunch of plots using a loop function, how to add title to reflect different plots. Specifically, for the code below, I generated 9 plots. I would like to add a title to each plot. For example, the titles will be respectively, plot1, plot 2, … plot 9. Thank you very much! Hanna par(mfrow=c(3,3), pty="s", pch=16, col="blue") for ( i in 1:9) { lm1 <- lm(log(run_res[2:11, i]) ~ log(level)) plot(log(level), log(run_res[2:11, i]), xlab="dllution levels", ylab="%PS-80") abline(lm1)} [[alternative HTML version deleted]]
Hi, try something like main=paste("plot",i) in the plot command. HTH, kd ________________________________________ Felad?: r-help-bounces at r-project.org [r-help-bounces at r-project.org] ; meghatalmazó: li li [hannah.hlx at gmail.com] K?ldve: 2014. j?nius 24. 15:17 To: r-help T?rgy: [R] Making several plots using a loop function Hi all, When making a bunch of plots using a loop function, how to add title to reflect different plots. Specifically, for the code below, I generated 9 plots. I would like to add a title to each plot. For example, the titles will be respectively, plot1, plot 2, ??? plot 9. Thank you very much! Hanna par(mfrow=c(3,3), pty="s", pch=16, col="blue") for ( i in 1:9) { lm1 <- lm(log(run_res[2:11, i]) ~ log(level)) plot(log(level), log(run_res[2:11, i]), xlab="dllution levels", ylab="%PS-80") abline(lm1)} [[alternative HTML version deleted]]
What about title(paste("plot", i)) ? Sarah On Tue, Jun 24, 2014 at 9:17 AM, li li <hannah.hlx at gmail.com> wrote:> Hi all, > When making a bunch of plots using a loop function, how to add title to > reflect different plots. > Specifically, for the code below, I generated 9 plots. I would like to add > a title to each plot. > For example, the titles will be respectively, plot1, plot 2, ? plot 9. > Thank you very much! > Hanna > > > > par(mfrow=c(3,3), pty="s", pch=16, col="blue") > for ( i in 1:9) { > lm1 <- lm(log(run_res[2:11, i]) ~ log(level)) > plot(log(level), log(run_res[2:11, i]), xlab="dllution levels", > ylab="%PS-80") > abline(lm1)} > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. >-- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org