- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前,我总是使用出色的 ReporteRs
包将 R 图形以矢量格式导出到 Powerpoint,如下所示
library(ReporteRs)
myplot = function() print(qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width, alpha = I(0.7)))
doc = pptx()
doc = addSlide(doc, slide.layout = "Blank")
doc = addPlot( doc, myplot, vector.graphic = TRUE, fontname="Arial",
offx = 0.1*dim(doc)$slide.dim["width"], offy = 0.05*dim(doc)$slide.dim["height"],
width = 0.8*dim(doc)$slide.dim["width"], height = 0.9*dim(doc)$slide.dim["height"])
writeDoc( doc, "plot.pptx")
我发现此工作流程中不方便的是我现在必须将绘图命令包装在一个函数中(使用 print()
表示 lattice
或 ggplot2
图,或者只是 return(plot())
用于基本 R 图),而且我不喜欢手动指定偏移量和大小(我通常更喜欢只得到一个几乎页面填充,幻灯片中的居中图表)。我只是想知道是否无法先绘制图(基本 R 图、lattice 图或 ggplot2 图),然后定义函数 export2PPT
将当前图形设备的输出捕获为函数,并将其传递给 ReporteRs
和 addPlot
以将绘图导出为 Powerpoint(居中且适当缩放) ),类似于函数 dev.copy2pdf
,其工作方式与导出为 PDF 相同?
一旦我们有了这样的函数,甚至可能 modify the grDevices
source code功能 windows() and savePlot()如果使用 windows()
设备,是否需要一个附加命令“文件...另存为 Powerpoint”?或者这是 R Core 人员要做的事情?
考虑到 MS Office/LibreOffice 的主导地位,我认为特别是在类里面使用,这将非常方便。(因为 Powerpoint 比 PDF 更容易编辑,允许人们轻松地对 R 图形的最终布局进行微小的更改,并且矢量输出至少与 PDF 一样好,而且还完全支持透明度 - 对于 PDF,我发现导入在 Inkscape 中通常有点错误,除非使用 Adobe Illustrator)
有人知道如何做到这一点吗?
编辑:与此同时,我找到了解决方案,并包装了导出函数,将当前事件的 R 图导出到 CRAN 包中的 powerpoint,请参阅 https://cran.r-project.org/web/packages/export/index.html和 https://github.com/tomwenseleers/export供演示使用。该包现在使用Officer包作为后端,因为ReporteRs已被弃用...
最佳答案
刚刚制作了一个新的 CRAN 包export
,它允许将当前事件图形设备中的 R 图以可编辑 (DrawingML) 矢量格式导出到 Powerpoint 或 Word(或 LibreOffice Impress/Writer)作为一行,完全支持透明度等,请参阅 https://cran.r-project.org/web/packages/export/index.html并进行演示 https://github.com/tomwenseleers/export
例如:
install.packages("export")
library(export)
导出格子
图的示例:
library(effects)
fit=lm(prestige ~ type + income*education, data=Prestige)
plot(Effect(c("income", "education"), fit),multiline=T, ci.style="bands")
graph2ppt(file="effect plot.pptx", width=7, height=5)
在 PPT 中右键单击“取消分组”后,可以看到很好的矢量格式:
通过使用文件...另存为...PDF,这些图表还可以从 Word 或 PPT 完美导出为(矢量格式)PDF,并且对布局进行细微调整比直接编辑要容易得多PDF。
如果 R Core 或 RStudio 用户希望包含此功能,请这样做 - 考虑到 Office 套件的主导地位和广泛使用,我认为在类里面使用会非常方便!
关于R:将当前事件的 R 图导出到 Powerpoint/Word/LibreOffice 的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31212659/
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
通过右键单击功能区并选择“从以下位置选择命令:宏”,可以从功能区的启用宏的 PowerPoint (pptm) 演示文稿中添加宏。 我希望它随时可用,所以我将 pptm 文件保存为加载项 (ppam)
我需要在 Latex Beamer 和 Powerpoint 中维护一些幻灯片。 (这是为了向其他地方的教师提供幻灯片,其中 90% 的教师不知道如何使用 Latex,也不愿意学习它。而我是 Linu
我有一个用于 PowerPoint 的任务 Pane 加载项,它可以帮助用户处理事件演示文稿上的任务。随着 Microsoft Office 在 Windows 以外的平台上越来越流行,使用 Java
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
不知何故,我丢失了 PowerPoint 中的 Storyboard 标签。我怎样才能恢复它?谢谢。 我同时使用 PowerPoint 2010 和 PowerPoint 2013 最佳答案 我遇到了
我用 plotly 生成了一个离线交互图。 我将绘图保存为 html 文件。有谁知道我可以将交互式绘图嵌入到 MS PowerPoint 中进行演示? 非常感谢! 最佳答案 PowerPoint 本身
我正在尝试从不同来源生成演示文稿。基本上我有大约 200 张幻灯片来自一些 PowerPoint 演示文稿。为了实现这一点,我使用了 OpenXml Sdk。程序流程如下: 打开模板演示 打开新演示文
是否可以在 PowerPoint 幻灯片中添加形状(或除纯文本或图像之外的任何其他内容)? 我在上面找不到任何东西,真的希望这是可能的。我已经在 UserVoice ( https://offices
我希望在 Linux 中以自动方式将 PPT 和 PPTX 文件转换为 Flash(或 flv)文件 - 所以我需要一个命令行实用程序。 有什么可用的选择吗? (目前我还没有找到)。 我也在寻找一个
我在 PowerPoint 2010 中制作了一个模块原型(prototype)。该模块在 PowerPoint 图表上绘制了一些线条和形状。我使用了 PowerPoint.Point(系列的数据点)
在 Word 中,您可以使用 Office.context.document.customXmlParts API 来访问自定义 xml。在 Excel 中,您必须使用 Excel.run((cont
我需要能够将 PowerPoint 2003 中的演示文稿(以编程方式)保存为 OpenXML(“.pptx”)。 我安装了 Microsoft Office 兼容包。这确实允许我从 PowerPoi
我的任务是在将当前 powerpoint 保存为 WMV 后获取电影帧。以下代码作为独立应用程序运行良好,但由于“CreateVideoStatus”作为 Powerpoint 加载项运行时始终为“P
我正在尝试从移动版 Safari 链接到一个 .pptx 文件,并在 PowerPoint 中打开该文件。根据 https://www.test.com/test.pptx 上的信息,我的链接看起来像
我为 PowerPoint (2010) 写了一个小的 VBA 宏,当鼠标悬停在某个形状上时,它会打开一个带有解释的弹出窗口。这很好用。 las,再次离开该区域时没有触发任何事件,所以我现在想扩展代码
我正在寻找注入(inject)的方法PresentationML 和/或 绘图ML 使用 Open XML SDK 或只是 System.IO.Packaging 进入打开的 PowerPoint 2
我有一个可以将幻灯片导出到 PowerPoint 的应用程序。我正在使用 Microsoft.Office.Interop.PowerPoint.dll 。这是汇编的第 11 个版本。我今天运行了应用
当 Microsoft Word 关闭时,可以取消关闭事件。对于 Excel 也是如此。 但是 PowerPoint 关闭事件没有取消标志。 是否可以通过其他方式取消事件? 最佳答案 在关闭事件中,您
我有一个 Excel 宏,可以从指定位置打开 PowerPoint 文件。 PowerPoint 文件是一个模板。 我需要根据模板设计创建一个新的演示文稿。 我的代码将打开模板而不是基于该模板的新演示
我是一名优秀的程序员,十分优秀!