用 R 图填满整个 PowerPoint 幻灯片? [英] Fill an Entire PowerPoint Slide with an R Plot?

查看:71
本文介绍了用 R 图填满整个 PowerPoint 幻灯片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用 R 绘图填充整个 PowerPoint 幻灯片?我想使用矢量图形(否则截图和裁剪将是一个解决方案).我也想避免手动触摸.

How can I fill an entire PowerPoint slide with an R plot? I'd like to use vector graphics (otherwise screenshot and crop would be a solution). I'd also like to avoid manual touches.

以下代码(摘自 这篇文章) 在填充标题和内容"幻灯片的内容"方面做得非常好.

The following code (grabbed from this post) does a perfectly fine job of filling the "Content" of a "Title and Content" slide.

library( ReporteRs )
require( ggplot2 )
mydoc = pptx( )
mydoc = addSlide( mydoc, slide.layout = "Title and Content" )
mydoc = addTitle( mydoc, "Plot examples" )
myplot = qplot(Sepal.Length, Petal.Length
               , data = iris, color = Species
               , size = Petal.Width, alpha = I(0.7)
)
mydoc = addPlot( mydoc, function( ) print( myplot ), vector.graphic=TRUE)
writeDoc( mydoc, file = "test plot.pptx" )

我认为我可以使用以下代码填充整张幻灯片:

I thought I might be able to fill an entire slide using the following code:

library( ReporteRs )
require( ggplot2 )
mydoc = pptx( )
mydoc = addSlide( mydoc, slide.layout = "Blank" )
#mydoc = addTitle( mydoc, "Plot examples" )
myplot = qplot(Sepal.Length, Petal.Length
               , data = iris, color = Species
               , size = Petal.Width, alpha = I(0.7)
)
mydoc = addPlot( mydoc, function( ) print( myplot ), vector.graphic=TRUE)
writeDoc( mydoc, file = "test plot.pptx" )

但是,我收到错误消息:

But, i get the error message:

Error in next_shape_pos(doc) : 
  shape of type 'plot' has no more room left to be displayed in the layout

我认为可能有一种解决方案,我可以创建新的 PowerPoint 幻灯片布局,内容填充整个幻灯片,然后另存为 PowerPoint 模板?但是我对这些东西不是很熟悉,并且开始觉得我错过了一些明显的东西.

I think there may be a solution where I create new PowerPoint slide layout with content filling the entire slide and then save as a PowerPoint template? But I'm not very familiar with this stuff and am starting to feel like I'm missing something obvious.

推荐答案

您已经有效地回答了自己的问题.您需要在 PowerPoint 中创建一个具有新布局的模板,该布局具有填充幻灯片的单个内容占位符.

You have effectively answered your own question. You need to create a template in PowerPoint with a new layout that has a single content placeholder filling the slide.

在 PowerPoint 2016 中,您将执行以下操作:

In PowerPoint 2016, you would do the following:

  • 文件 -> 新建 -> 空白演示文稿
  • 删除第一张(也是唯一一张)幻灯片
  • 查看 -> 幻灯片母版
  • 幻灯片母版 -> 插入布局
  • 删除此布局上的所有现有占位符
  • 幻灯片母版 -> 插入占位符 -> 内容
  • 调整新占位符的大小以填充幻灯片
  • 右键单击左侧布局列表中的布局
  • 重命名布局
  • 整页内容"
  • 文件 -> 另存为 -> 浏览
  • 选择演示模板的位置和名称(例如Documents/R/BlankPresentation.pptx")

现在运行以下 R 代码:

Now run the following R code:

library(ReporteRs)
library(ggplot2)
mydoc <- pptx(template = "path to presentation template saved above")
mydoc <- addSlide(mydoc, slide.layout = "Full page content")
myplot <- qplot(
  Sepal.Length,
  Petal.Length,
  data = iris,
  color = Species,
  size = Petal.Width,
  alpha = 0.7
)
mydoc <- addPlot(mydoc, function() print(myplot), vector.graphic = TRUE)
writeDoc(mydoc, file = "test plot.pptx")

这篇关于用 R 图填满整个 PowerPoint 幻灯片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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