从R创建可编辑的图 [英] Create Editable plots from R

查看:204
本文介绍了从R创建可编辑的图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中创建了一系列图(我使用的是ggplot2,但这不是必需的),我希望能够保存我的输出,以便随后可以对其进行编辑,以便进一步使用。例如,我可能我想知道ggplot2有一个保存命令,但似乎产生pdf或位图,两者都不是特别可编辑的。



其他人如何做到这一点?任何好主意?



以下是一些示例代码,用于生成示例图;

 <$ c (c(1:4)),data1 = rnorm(400,100,sd = 15))
数据帧$ data2 < - 数据帧dataframe $ data1 * c(0.25,0.5,0.75,1)
dataframe
testplot< -qplot(x = fac,y = data2,data = dataframe,color = fac,geom = c(boxplot ,jitter))
testplot

谢谢

Paul。

解决方案

感谢您的回答,我已经玩过这个,来自我朋友Google的帮助我找到了 Cairo 包,它允许创建svg文件,然后我可以在 Inkscape 中编辑这些文件。

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

现在我只需要进行各种设置,以便在写入文件之前获得我的情节。


I'm creating a series of plots in R (I'm using ggplot2, but that's not essential) and I want to be able to save my output so I can then edit it for furthur use, For instance, I might want to move legends about, or adjust colours etc. I have seen that ggplot2 has a save command but that seems to produce pdf's or bitmaps, neither of which are particularly editable

How do other people do this ? Any good ideas ?

Here's some sample code to produce a sample plot;

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

Thanks

Paul.

解决方案

Thanks for the answers, I've played around with this, and after some help from my friend Google I found the Cairo package, which allows creation of svg files, I can then edit these in Inkscape.

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()

Now I just have to play around with the various settings to get my plot as good as it can be before writing the file.

这篇关于从R创建可编辑的图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆