问题
I created three overlapping plots in R using the diamonds data set using the viewports below. Is it possible to get them formatted the same way [overlapping] into a .pdf file?
vp <- viewport()
sbvp <- viewport(width=1,height=1,x=.5,y=.5)
sbvp1 <- viewport(width=.4,height=.2,x=.28,y=.18)
sbvp2 <- viewport(width=.4,height=.2,x=.8,y=.72)
print(p0, vp=sbvp)
print(p1, vp=sbvp1)
print(p2, vp=sbvp2)
Tried two separate ways [one below]. I understand ggsave wasn't working because it just works on the last plot, but am not even sure if using viewports in multiplot() is possible. It doesn't seem possible because of the column requirement, but this is what I ran:
pdf("plot.pdf", width = 6.8, height = 4.7)
multiplot(sbvp,sbvp1,sbvp2)
dev.off()
system('open "plot.pdf"')
Thanks,
来源:https://stackoverflow.com/questions/40145252/how-to-save-inset-viewport-plots-into-pdf-file-using-grid-and-ggplot2-packages