全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2437 8
2012-03-07
Dear All:

I have a 2 by 2 plots per page (4 plots/page) for total 12 pages (48 IDs) generated by the below example codes. How do I specify a title at the top center of each page and add a legend in the middle center of each page. I know mtext can add title and legend can add legend, but my problem is how to add them to each page (12 pages) not each plot (48 plots, 4 plots/page).

par(mfrow=c(2,2),mar=c(5,5,4,4))

for (i in unique(tak700$ID)){
j=tak700$ID==i

plot(tak700$TIME[j], tak700$DV[j], type='n', xlim=c(0,max(tak700$TIME[j])), ylim=c(0,max(tak700$DV[j],tak700$IPRE[j],tak700$PRED[j])),xlab='Time(hr)', ylab='Plasma Concentration(ng/ml)',cex=0.8)

lines(tak700$TIME[j], tak700$DV[j], type='b', col=2, pch=1, lwd=2, lty=4, cex=0.9)
}

But how and where to add the below example commands to generate title and legend per page for total 12 pages?

legend(80,10,col=6,lty=c(1,4),c('Predicted median','Predicted 95% PI'),lwd = 2,cex=1.1,bty='n')

mtext(outer=T, 'Phase II at steady state', side=3, line=-2,cex=1.2,col=2)


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-3-7 06:17:59
def.par <- par(no.readonly = TRUE)
x <- matrix(c(1,0,2,0,5,0,3,0,4), nrow = 3, byrow = T)
layout(x, c(3, 1, 3), c(3, 1, 3), TRUE)
oldMar1 <- par(oma = c(0, 0, 3, 0), mar = c(2.2, 1.5, 2, 0))
hist(rnorm(1000), col = 1)
hist(rnorm(1000), col = 2)
hist(rnorm(1000), col = 3)
hist(rnorm(1000), col = 4)
mtext("All histograms", outer = TRUE, cex = 1.5)
oldMar2 <- par(mar = c(0, 0, 0, 0))
plot.new()
legend('center', legend = 1:4, lwd = 3, col = 1:4)
par(def.par)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-7 06:19:05
Untitled.png
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-7 08:55:57
版主一出手,就知有木有!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-7 09:25:49
Thanks but this is not what I want. basically, I need add title and legend for 12 pages, each page has four plots from for loop, and each page need has title and legend. you only generate one page, and it is easy to add title and legend on only one page containing four plots.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-7 09:55:51
verbatim 发表于 2012-3-7 09:25
Thanks but this is not what I want. basically, I need add title and legend for 12 pages, each page h ...
add a counter i. If i can be divided by four, add the title and legend.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群