gpt4 book ai didi

R eps 导出和导入 Word 2010

转载 作者:行者123 更新时间:2023-12-04 09:36:16 24 4
gpt4 key购买 nike

我在从 R 导出 eps 文件并导入 Word 2010 时遇到问题。

我正在使用 ggplot2情节,例如

library(ggplot2)
p <- qplot(disp,hp,data=mtcars) + stat_smooth()
p

即使在调用 setEPS() 之后以下都不是可以成功导入的生成文件。
ggsave("plot.eps")

postscript("plot.eps")
print(p)
dev.off()

奇怪的是,如果我使用 File 制作情节-> Save As -> Postscript从 GUI 的菜单中,可以正确导入。但是,当 Word 文档随后导出为 pdf 时,图形中的字体有点锯齿状。

所以我的问题是:
  • ( ggsave/postscript ) 设置的哪些组合允许我生成可以导入 Word 2010 的 eps 文件?
  • 当 Word 文档导出为 pdf 时,如何确保字体保持清晰?

  • 更新

    经过更多调查后,我对 cairo_ps 有了更多的运气。生产地 block 。但是,导入 Word 时不会显示任何文本。

    此外,在检查了 latex 文档中的各种 eps 输出( cairo_ps,从 GUI 保存, ggsave)后,Word 中的 eps 导入过滤器似乎很差,因为打印/pdf 输出与质量不匹配的 latex 文件。 ggsave版本(使用 postscript )确实存在其他两种方法所没有的颜色问题。

    结论是这是一个 Word 问题,因此是 fortune(109)。不适用。我很高兴被证明不是这样,但我会将答案和赏金奖励给任何能够提供可以以命令形式复制 GUI 输出的命令的人。

    最佳答案

    这对我有用...遵循 postscript 中的建议帮助页面:

     postscript("RPlot.eps", height = 4, width = 4, horizontal = FALSE, onefile = FALSE,
    paper = "special")
    library(ggplot2)
    p <- qplot(disp,hp,data=mtcars) + stat_smooth()
    p
    #geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to #change the smoothing method.
    #Warning message:
    #In grid.Call.graphics(L_polygon, x$x, x$y, index) :
    # semi-transparency is not supported on this device: reported only once per page
    dev.off()
    #quartz
    # 2

    最后有趣的东西让你注意到这只是一个经过 Mac 测试的解决方案,无论如何。

    编辑:我刚刚使用 R 版本 2.15.1 (2012-06-22) 对其进行了测试——“烤棉花糖”:平台:i386-pc-mingw32/i386(32 位)和 Win XP 中的 MS Word 2007 并且它有效.命令是插入/图片.../选择 eps 格式/选择文件。

    Edit2:除了直接使用 postscript 设备之外,还有另一种保存方法。带有 "eps" 的 savePlot 方法模式在 Windows 中可用(但在 Mac 中不可用)。我同意这些字体不像在 Mac 上显示的那样流畅,但我可以看出使用 savePlot 保存和从交互式窗口使用 save as 在质量上没有区别。
    savePlot(filename = "Rplot2", type = "eps", device = dev.cur(), restoreConsole = TRUE)
    savePlot来电 (.External(CsavePlot, device, filename, type, restoreConsole))

    关于R eps 导出和导入 Word 2010,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12747916/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com