问题
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