2015-05-12 34 views
0

我需要打印一个单倍型网络以高质量png。但是,为了按照我想要的方式获得情节,我需要使用交互功能来更改某些内容。当我使用png()打印情节时,我无法进行这些更改,因为它会打印到PDF而不是打印到打印窗口。有什么办法可以将它打印到打印窗口以及png?以交互方式操作图形时在R中打印高质量图块

的情节重复的例子:

install.packages("pegas") 
library(pegas) 
data(woodmouse) 
net <- haploNet(haplotype(woodmouse)) 
plot(net) 
o <- replot() # interactive 
## click to rearrange the network at will... 
## then do a different plot using the same coordinates: 
plot(net, bg = "red", labels = FALSE, show.mutation = 2) 
replot(o) # not interactive 

我不想因为它产生的图是低质量的使用出口按钮RStudio。

回答

1

可以将当前的情节保存到使用recordPlot()一个变量,那么图形设备更改为png和重播使用replayPlot保存的情节。例如:

#same data as above 
o <- plot(net, bg = "red", labels = FALSE, show.mutation = 2) 
replot() # interactive - do your thing 

myplot <- recordPlot() 
png("recordedPlot.png") 
replayPlot(myplot) 
dev.off()