【问题标题】:Problems with ggplot when use markdown to PDF使用markdown转PDF时ggplot的问题
【发布时间】:2021-08-30 08:50:12
【问题描述】:

当我在 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 字体数据库中找不到字体系列

我该如何解决这个问题?

【问题讨论】:

  • 它有助于 SEO,如果您在文本中包含实际错误而不是图像,它将帮助其他读者:图像破坏了 SEO 和屏幕阅读器。请edit您的问题并添加文本本身(通常在代码块中)。谢谢。
  • 尝试将dev = "cairo_pdf" 添加到块选项中。
  • 控制台中的@r2evans 没有出现错误,但反正我写了。
  • @henrik_ibsen 非常感谢,这就是解决方案

标签: r ggplot2 plot r-markdown themes


【解决方案1】:

解决方案是如 henrik_ibsen 所说,将 dev = "cairo_pdf" 添加到块选项中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-27
    • 2013-05-01
    • 2021-05-30
    • 2012-10-16
    • 2018-04-25
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多