R: Open new graphic device with dev.new() does not work

蹲街弑〆低调 提交于 2019-12-24 14:34:39

问题


I have a problem with opening a new graphics device to make a new plot.

The code is like:

par(mfrow = c(1, n.groups),pty="s")
if (n.groups == 3){
        par(mfrow = c(2, 2) )  
} else if (n.groups == 5 | n.groups == 6)  {
       par(mfrow = c(3, 3))
}  
QQ <- tapply(data$Measurement,data$Group,qqnorm,plot.it=T, main = "Q-Q Plot")
...  
some other lines
...
grp.plot <- ggplot(group.join, aes(x=Group,y=mean)) + 
    geom_bar(stat="identity")
box.plot <- ggplot(data = brcp.df, aes(x = Group, y = Measurement)) + 
    geom_boxplot()
grd <- arrangeGrob(grp.plot, box.plot, ncol=2,nrow=2)
dev.new()
grid.draw(grd)

The second plot made with grid.draw() is plotted on top of the first one.

If instead I do this:

dev.off()
dev.new()
grid.draw(grd)

The last plot is not overlapped but the first plot disappears.

来源:https://stackoverflow.com/questions/32499611/r-open-new-graphic-device-with-dev-new-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!