ggplot hex color is different than latex hex color on pdf when knitting with rmarkdown

问题描述 投票:0回答:0

在 ggplot 中使用特定的十六进制代码作为填充颜色并在乳胶中使用相同的十六进制代码进行样式创建绘图时,颜色在 PDF 中略有不同。

乳胶创建的颜色非常接近十六进制,而 ggplot 则更远。

乳胶#1360AA ggplot 是 #145FAA

所需的十六进制颜色是#1260AA

Color_Issue.Rmd

    ---
    documentclass: scrreprt
    classoption: a4paper
    fontsize: 11pt
    params: 
       set_title: "Bug"
    output: 
      pdf_document:
         includes:
          in_header: preamble.tex
    ---

    \fboxsep=4cm
    \fcolorbox{sblue}{sblue}{\null}

    ```{r box, warning=FALSE, message=FALSE}

    library(tidyverse)


    df <- data.frame(
      x = c(1, 2),
      y = c(2, 2))

    ggplot(df, aes(x, y)) +
      geom_tile(aes(), fill = "#1260AA")

preamble.tex

    \usepackage{xcolor} \definecolor{sblue}{HTML}{1260AA}

如何确保 PDF 中不同语言的颜色相同?

r ggplot2 latex r-markdown
© www.soinside.com 2019 - 2024. All rights reserved.