【问题标题】:How to resize images in Xaringan presentation?如何在 Xaringan 演示文稿中调整图像大小?
【发布时间】:2020-02-23 03:47:20
【问题描述】:

我正在尝试从 ioslide 切换到 xaringan。我无法正确调整 ggplot 图像的大小以使其全屏显示或至少占用尽可能多的空间。我同时使用了fig.height/widthout.height/width 参数,但只有一个维度发生了变化。有没有更好的方法来调整图像的大小? 这是设置:

---
title: ""
author: ""
institute: ""
date: "`r Sys.Date()`"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
      ratio: 16:9
---
#```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(fig.retina=2)

library(Cairo)
library(cairoDevice)
library(tidyverse)
library(kableExtra)
#```

--- 

# Plot

#```{r echo=FALSE, out.height=450, out.width= 2000}
knitr::include_graphics("img/Rplot01.svg")
#```

结果如下:

我想尽可能扩大图像

【问题讨论】:

  • 对于选项out.widthout.height,输入值需要是一个字符串。改用“100%”(带引号)。

标签: html css r r-markdown xaringan


【解决方案1】:

设置图片大小

您可以使用markdown标签,例如:

![:scale 50%](image.jpg)

this

作为背景图片:

在 Xaringan 中,您可以像这样添加图像:

---
class: inverse, center, middle
background-image: url(img/Rplot01.svg")
background-size: contain

请检查url中的信息是否正确。

作为指南,您可以看到使用this code 生成的this presentation(链接将您带到幻灯片的第 9 号幻灯片)(参见第 76 行)

【讨论】:

  • 感谢@Orlando Sabogal 的回答。但我需要简单地扩展我的图像而不使用它作为背景。问题是我无法正确使用块选项来调整图像大小
  • 我编辑了答案。我认为您可以使用降价添加它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-11-14
  • 2021-04-20
  • 1970-01-01
  • 2019-10-13
  • 2020-06-11
  • 2019-09-25
  • 1970-01-01
相关资源
最近更新 更多