Reputation: 255
I am using this code for plotting list of variables in a single page:
plot30 <- list(HMn25_30,HMn28_30,HMn29_30,HMn31_30,HMn32_30)
par(mfrow=c(2,3))
for (i in plot30) {
plot(i, type = "o", pch = 16, lty = 2, col = "Black", xlab = "Hour 2007/09/30" , ylab = "Ambient Tempreture")
}
Result of this code:
I wanted to add titles such as {Node 25,Node 28,Node 29,Node 31,Node 32} to the plots.
Any suggestion?
Upvotes: 1
Views: 1130
Reputation: 61154
try to add the following in your for loop
plot30 <- list(HMn25_30,HMn28_30,HMn29_30,HMn31_30,HMn32_30)
Main <- c('Node 25','Node 28','Node 29','Node 31','Node 32')
par(mfrow=c(2,3))
for (i in seq_along(plot30)) {
plot(plot30[[i]], type = "o", pch = 16, lty = 2, col = "Black", xlab = "Hour 2007/09/30" , ylab = "Ambient Tempreture", main=Main[i])
}
Upvotes: 3
Reputation: 263332
This is the construct you should expand from:
plot30 <- list(myplot)
names(plot30)<- c('myplot1')
for (i in seq_along(plot30) ) {pname <- names(plot30)[i]
plot(plot30[i], main=pname)
}
Upvotes: 2