r - 使用markdown转PDF时ggplot的问题
问题描述
当我在 Rstudio 的控制台中运行它时,我的绘图似乎没有任何问题,但是当我尝试使用 Rmarkdown 获取 PDF 输出时,代码会出现错误:
library(tidyverse)
mtcars %>% ggplot(aes(x = mpg, y = cyl)) + geom_line() +
hrbrthemes::theme_modern_rc() +
labs(title = "Plot")
这是错误:
grid.Call.graphics 中的错误(C_text, as.graphicsAnnot(x$label), x$x, x$y, : invalid font type Calls: ... drawDetails -> drwDetails.text -> grid.Call.graphics Además : 有 50 个警告(使用 warningswarnings() 查看第 50 个) Ejecución interrumpida
在 grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... : 在 Windows 字体数据库中找不到字体系列
我怎么解决这个问题?
解决方案
正如 henrik_ibsen 所说,解决方案是将 dev = "cairo_pdf" 添加到块选项中
推荐阅读
- html - 如果使用 target="_blank" 将用户重定向到我的网站主页到另一个页面(同一网站),是否必须使用 rel="noreferrer"?
- sql - 在创建 SSIS 目录时;我在代码 PAGE 上失败了
- excel - 防止自动筛选条件从字符串更改为日期
- regex - 如何创建具有多个条件的 RegEx?
- java - 澄清一下这个链表的实现
- python - ^ 不支持的操作数类型:“字节数组”和“int”(按位运算符)
- python - 面对 chromedriver 意外退出。状态代码为:127 在 AWS ec2 上使用带有 docker 和 python 3.7 的 Headless chrome 浏览器
- sql - 解决“cannot perform a DML operation inside a query”
- python - 如何使用 python PIL 获取图像中的一组颜色
- excel - 如何更新源数据由宏更新的数据透视表?