Is it possible to build a graph on several output devices at once? I tried:
getwd() pdf("level1.pdf") pdf("level2.pdf") png("level3.png") x=1:10 y=1:10 plot(x, y) dev.off() # close level3 dev.off() # close level2 a=10:20 b=-10:0 plot(a,b) dev.off() # close level1
The plot of XY goes only to level3.png. (I have to go into all 3 files)
level3.png
Oddly enough, the AB chart goes into level2.pdf, and I expected it to be written on level1.pdf, since level2.pdf should already be closed?
, "" , . , , (/ ). , .
:
dev.List()
dev.cur()
dev.set()
dev.next()
dev.prev()
pdf("level1.pdf") pdf("level2.pdf") png("level3.png") ## list the devices dev.list() pdf pdf png:level3.png 2 3 4 ## current device dev.cur() png:level3.png ## that why The XY plot goes only into this device 4 ### this will go in the current device x=1:10 y=1:10 plot(x, y) ## change the active device dev.set(dev.next()) pdf 2 ### close all devices graphics.off() ## list the devices dev.list() NULL
, :
pdf("level1.pdf") pdf("level2.pdf") png("level3.png") dev.off() # close level3 dev.off() # close level2 dev.cur() pdf ## plot A,B goes on this device 3
ggplot2 print :
ggplot2
print
library(ggplot2) p <- ggplot(data.frame(x=1:10, y=1:10), aes(x=x, y=y)) + geom_point() pdf('a.pdf') print(p) dev.off() png('b.png') print(p) dev.off()
, ggsave ( , , - Ubuntu):
ggsave
ggsave('a.pdf', p) ggsave('b.png', p)
"" , ggplot2 , .