【问题标题】:knitr render missing labels in ggplotsknitr在ggplot中呈现缺少的标签
【发布时间】:2021-01-23 23:16:09
【问题描述】:

我正在容器化 Snakemake 管道所需的软件。其中包括 R 4.0.2 安装以及 Tidyverse 和一些 Bioconductor 软件包(全部通过 Conda Forge)。大多数情况下似乎一切正常,但是,一步通过knitr::render 呈现.Rmd 文档。文档渲染运行没有错误,但 HTML 中的 ggplot 图像缺少所有标签:

当我在同一台机器上的 Conda 环境中运行此代码时,它运行良好。我怀疑在需要安装在 Docker 容器中的图像中呈现文本需要一些库。 有没有人经历过这种情况?是否需要将特定库添加到容器中才能解决此问题?

The container image 是公开的,如果有人想用它进行测试。


附加信息

会话信息

这是呈现的 HTML 的 sessionInfo() 输出。

## R version 4.0.2 (2020-06-22)
## Platform: x86_64-conda_cos6-linux-gnu (64-bit)
## Running under: Debian GNU/Linux 10 (buster)
## 
## Matrix products: default
## BLAS/LAPACK: /opt/conda/lib/libopenblasp-r0.3.10.so
## 
## locale:
##  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
## [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] cowplot_1.1.0   magrittr_1.5    forcats_0.5.0   stringr_1.4.0  
##  [5] dplyr_1.0.2     purrr_0.3.4     readr_1.3.1     tidyr_1.1.2    
##  [9] tibble_3.0.3    ggplot2_3.3.2   tidyverse_1.3.0 Matrix_1.2-18  
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.1.0 xfun_0.18        haven_2.3.1      lattice_0.20-41 
##  [5] colorspace_1.4-1 vctrs_0.3.4      generics_0.0.2   htmltools_0.5.0 
##  [9] yaml_2.2.1       blob_1.2.1       rlang_0.4.7      pillar_1.4.6    
## [13] withr_2.3.0      glue_1.4.2       DBI_1.1.0        dbplyr_1.4.4    
## [17] modelr_0.1.8     readxl_1.3.1     lifecycle_0.2.0  munsell_0.5.0   
## [21] gtable_0.3.0     cellranger_1.1.0 rvest_0.3.6      evaluate_0.14   
## [25] knitr_1.30       fansi_0.4.1      broom_0.7.1      Rcpp_1.0.4.6    
## [29] scales_1.1.1     backports_1.1.10 jsonlite_1.7.1   farver_2.0.3    
## [33] fs_1.5.0         hms_0.5.3        digest_0.6.25    stringi_1.5.3   
## [37] grid_4.0.2       cli_2.0.2        tools_4.0.2      crayon_1.3.4    
## [41] pkgconfig_2.0.3  ellipsis_0.3.1   xml2_1.3.2       reprex_0.3.0    
## [45] lubridate_1.7.9  assertthat_0.2.1 rmarkdown_2.4    httr_1.4.2      
## [49] rstudioapi_0.11  R6_2.4.1         compiler_4.0.2

【问题讨论】:

  • This github issue 可能是相关的。
  • @ManavalanGajapathy 这正是问题所在 - 非常感谢!他们在那里提供了多种解决方案,但我发布了一个我认为通用的解决方案。
  • 很高兴能帮上忙!

标签: r docker ggplot2 r-markdown knitr


【解决方案1】:

@ManavalanGajapathy 在评论中指出的The GitHub issue 与我所经历的相同。总之,我开始使用的 Miniconda3(基于 Debian)Docker 容器不包括 R 可以在绘图中使用的字体。该线程讨论了在 Docker 级别 (apt-get) 和 Conda 级别安装字体的多种选项。

我最终选择的解决方案是将依赖项 fonts-conda-ecosystem 添加到我的 Conda 环境中。现在的最终输出是:

【讨论】:

    猜你喜欢
    • 2014-07-30
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 2015-10-12
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 2023-01-22
    相关资源
    最近更新 更多