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

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

问题描述

我正在 R 中创建一系列图(我使用的是 ggplot2,但这不是必需的)并且我希望能够保存我的输出,以便我可以对其进行编辑以供进一步使用,例如,我可能想要移动图例,或调整颜色等.我已经看到 ggplot2 有一个保存命令,但似乎生成 pdf 或位图,这两者都不是特别可编辑的

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

谢谢

保罗.

推荐答案

感谢您的回答,我已经解决了这个问题,在我朋友 Google 的帮助下,我找到了 Cairo 包,允许创建 svg 文件,然后我可以在 Inkscape.

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天全站免登陆