【问题标题】:R Draws Plots with Rectangles Instead of TextR用矩形而不是文本绘制图
【发布时间】:2020-02-25 19:08:55
【问题描述】:

我正在使用snakemake 构建管道,并使用condasingularity 环境来确保可重复性。我遇到了一个错误,我的地块上的文本被矩形替换

在 Linux 和 Mac 系统上试验管道并禁用奇异容器后,问题似乎源于缺少字体库,因为当我仅使用 conda (--use-conda ) 在我的 Mac 上。

奇点容器是从使用 Debian GNU/Linux 的 this miniconda docker 镜像构建的。 我设法创建了一个不会绘制文本的最小示例管道。

# Snakefile
singularity: "docker://continuumio/miniconda3"

rule all:
    input:
        "mtcars-plot.png"

rule plot_mtcars:
    output:
        "mtcars-plot.png"
    conda:
        "minimal.yaml"
    script:
        "mtcars-test.R"
# mtcars-test.R
library(ggplot2)
png("mtcars-plot.png")
ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot()
dev.off()
# minimal.yaml
channels:
    - bioconda
    - conda-forge
    - defaults
dependencies:
    - r-base =3.6
    - r-ggplot2

要绘制断线图,请运行管道

snakemake --use-conda --use-singularity

在 Debian GNU/Linux 上使用 R 正确绘制文本可能会缺少哪些软件包/库?

【问题讨论】:

标签: r linux pipeline snakemake singularity-container


【解决方案1】:

感谢 MrFlick 的评论,第二个 link 表示 R 中的文本支持需要 mscorefonts 包。

mscorefonts 添加到conda 环境可以解决此问题

# minimal.yaml
channels:
    - bioconda
    - conda-forge
    - defaults
dependencies:
    - r-base =3.6
    - r-ggplot2
    - mscorefonts

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    相关资源
    最近更新 更多