简体   繁体   English

在滑动演示中为动画调整视频框的大小 (RMarkdown)

[英]Resize videobox for animation in slidy presentation (RMarkdown)

I am making a presentation that contains an animation with a grid of plots in slidy (rmarkdown).我正在制作一个演示文稿,其中包含一个带有滑动(rmarkdown)中的绘图网格的动画。 The videobox is a bit too large for the slide and I would like to reduce it.视频盒对于幻灯片来说有点太大了,我想缩小它。 My presentation is similiar to this one:我的介绍与这个类似:

---
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) 
}
```

I would like to reduce the video tag's width from it's default value (864) to something like 650. I can easily do it in the .html, but, I rather change it from the .rmd document.我想将视频标签的宽度从它的默认值 (864) 减少到 650 之类的东西。我可以在 .html 中轻松地做到这一点,但是,我宁愿从 .rmd 文档中更改它。

So far I tried:到目前为止,我尝试过:

  • Adding the width parameter to aniopts, (does not have any effect)给aniopts添加width参数,(没有任何作用)
  • Playing around with fig.height and fig.width, (they change the text's size)玩弄 fig.height 和 fig.width,(它们会改变文本的大小)
  • Playing around with heights and widths parameters in grid.arrange, (same as before)在 grid.arrange 中使用高度和宽度参数,(与之前相同)

Any help will be appreciated.任何帮助将不胜感激。

This works for me这对我有用

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

You can also center the video if you want如果需要,您也可以将视频居中

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

Your rmd will look like你的 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) 
}
```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM