Aki*_*ira 6 svg r ggplot2 r-markdown
使用 JupyterLab 时,有一个命令%config InlineBackend.figure_format = 'svg'将绘图显示为svg. 质量很棒。我想问一下Rnotebook是否有类似的命令,即
将 Rnotebook 内的绘图显示为svg.
将输出 html 中的绘图显示为svg.
对于要生成 svg 输出的每个代码块,只需设置dev = 'svg'chunk 选项即可。knitr::opts_chunk$set(dev = 'svg')或者您可以在 Markdown 文档的开头全局设置此选项。
将以下内容保存为.Rmd文件,编织,看看会得到什么。
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(dev = 'svg') # set output device to svg
```
A simple plot, as svg file:
```{r}
library(ggplot2)
ggplot(mtcars, aes(mpg, disp, color = hp)) +
geom_point() +
scale_color_viridis_c()
```
Run Code Online (Sandbox Code Playgroud)