我创造了一系列的地块R(我采用ggplot2,但这是不必要的),并且我希望能挽救我的输出所以然后我就可以进行编辑,用于进一步使用,例如,我可能想要移动传说有关,或者调整的颜色等等。我已经看到,ggplot2有一个保存的命令,但是,似乎产生pdf或位图,既不是特别的编辑

怎么其他的人这么做吗?任何有良好的想法?

这里是一些样品代码产生一个取样计划;

library(ggplot2)
dataframe<-data.frame(fac=factor(c(1:4)),data1=rnorm(400,100,sd=15))
dataframe$data2<-dataframe$data1*c(0.25,0.5,0.75,1)
dataframe
testplot<-qplot(x=fac, y=data2,data=dataframe, colour=fac, geom=c("boxplot", "jitter"))
testplot

感谢

保罗。

有帮助吗?

解决方案 3

谢谢你的答案,我已经打了围绕着这一点,并经过一些帮助我的朋友谷歌,我发现的 开罗 包,其中允许设立svg文件,然后我就可以编辑这些 .

library(Cairo)
Cairo(600,600,file="testplot.svg",type="svg",bg="transparent",pointsize=8, units="px",dpi=400)
testplot
dev.off()
Cairo(1200,1200,file="testplot12200.png",type="png",bg="transparent",pointsize=12, units="px",dpi=200)
testplot
dev.off()

现在我只需要玩弄各种各样的设置让我的剧情为好,因为它可以前编写的文件。

其他提示

其它可编辑的格式:

看一看help(devices)为其他格式,其是可用的:。这些包括svgpictexxfig,所有这些都是可编辑到较大或较小的程度上

请注意,PDF可以使用适用于苹果的OSX的Omnigraffle工具进行编辑,例如。

其他的方式来记录绘图数据:

在此外,还可以记录r的给图形子系统命令购买重复它 - 看一看dev.copy

 Most devices (including all screen devices) have a display list
 which records all of the graphics operations that occur in the
 device. 'dev.copy' copies graphics contents by copying the display
 list from one device to another device.  Also, automatic redrawing
 of graphics contents following the resizing of a device depends on
 the contents of the display list.

使用RSCRIPT以创建可重复,可编辑情节:

我通常采取第三种策略,这是我的R对话复制到一个文件RSCRIPT,我可以重复运行和调整的绘图命令,直到我想要做什么:

#!/usr/bin/Rscript
x = 1:10
pdf("myplot.pdf", height=0, width=0, paper="a4")
plot(x)
dev.off();

使用ggplot和晶格,您可以使用save保存剧情对象到磁盘,然后后来load它并修改它。例如:

save(testplot, file = "test-plot.rdata")

# Time passes and you start a new R session
load("test-plot.rdata")
testplot + opts(legend.position = "none")
testplot + geom_point()

右击输出情节鼠标 复制为图元文件 然后保存积成Word文档(右键单击编辑图片隐蔽的情节到Microsoft Office绘图对象)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top