10

我正在尝试从 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")
#```

这是结果: 在此处输入图像描述

我想尽可能扩大图像

4

1 回答 1

12

设置图像的大小

您可以使用降价标签,例如:

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

看到这个

作为背景图片:

在 Xaringan 中,您可以添加如下图像:

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

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

作为指南,您可以查看使用此代码生成的此演示文稿(链接将您带到第 9 号幻灯片,其中是图像)(请参阅第 76 行)

于 2019-10-27T17:32:37.300 回答