【问题标题】:Resize videobox for animation in slidy presentation (RMarkdown)调整滑动演示中动画的视频框大小(RMarkdown)
【发布时间】:2016-10-14 14:52:37
【问题描述】:

我正在制作一个演示文稿,其中包含一个动画,其中包含一个滑动网格 (rmarkdown)。视频框对于幻灯片来说有点太大了,我想缩小它。 我的演示文稿与此类似:

---
title: "Adbd"
output: slidy_presentation
---

## Animation

```{r animation1,echo=FALSE,fig.align='center', fig.show='animate', aniopts='controls,width=0.1', fig.height=9, fig.width=9,fig.retina=2}
for(i in 1:2){
  library(ggplot2)
  library(gridExtra)
  p1 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,6)+ylim(9,35)
  p2 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,8)+ylim(9,35)
  p3 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,8)+ylim(6,35)
  p4 <- ggplot(mtcars, aes(wt, mpg, label=rownames(mtcars)))+geom_point()+xlim(1,8)+ylim(9,35)+ geom_text()

  grid.arrange(p1,p2,p3,p4, nrow=2, ncol=2) 
}
```

我想将视频标签的宽度从它的默认值 (864) 减少到 650 之类的东西。我可以在 .html 中轻松地做到这一点,但是,我宁愿从 .rmd 文档中更改它。

到目前为止我尝试过:

  • 在aniopts中添加width参数,(没有任何作用)
  • 玩弄 fig.height 和 fig.width,(它们会改变文本的大小)
  • 在 grid.arrange 中使用高度和宽度参数,(与之前相同)

任何帮助将不胜感激。

【问题讨论】:

    标签: r animation knitr gridextra slidy


    【解决方案1】:

    这对我有用

    video {
      width:  650px  !important;
      height:  auto  !important;
    }
    

    您也可以根据需要将视频居中

    video { 
      display: block;
      margin: 0 auto;
    }
    

    你的 rmd 看起来像

    ---
    title: "Adbd"
    output: slidy_presentation
    ---
    
    <style>
    
    video {
      width:  650px  !important;
      height:  auto  !important;
    
      /* center the player */
      display: block;
      margin: 0 auto;
    }
    
    </style>
    
    ## Animation
    
    ```{r animation1,echo=FALSE,fig.align='center', fig.show='animate', aniopts='controls,width=0.1', fig.height=9, fig.width=9,fig.retina=2}
    for(i in 1:2){
      library(ggplot2)
      library(gridExtra)
      p1 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,6)+ylim(9,35)
      p2 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,8)+ylim(9,35)
      p3 <- ggplot(mtcars, aes(wt, mpg))+geom_point()+xlim(1,8)+ylim(6,35)
      p4 <- ggplot(mtcars, aes(wt, mpg, label=rownames(mtcars)))+geom_point()+xlim(1,8)+ylim(9,35)+ geom_text()
    
      grid.arrange(p1,p2,p3,p4, nrow=2, ncol=2) 
    }
    ```
    

    【讨论】:

    • 非常感谢!我不知道我可以覆盖 CSS 中的 width 属性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-04
    • 2023-03-16
    相关资源
    最近更新 更多