ggplot2:为什么半透明+ pdflatex 会导致比普通 PDF 字体更重?

2024-05-07

ggplot2:为什么半透明+ pdflatex 会导致比普通 PDF 字体更重?

我遇到了一个问题pdf()在 R 中输入,然后pdflatex-ing ggplot2 图像会导致同一页面上的所有文本与图像变得粗体,但仅当alpha

require("ggplot2")
"%_%" <- function(a, b) paste(a, b, sep="")
test <- function(filename, alpha)
{
  pdf(filename %_% "-fig.pdf")
  p <- ggplot(mtcars, aes(wt, mpg)) + geom_point(alpha=alpha)
  print(p); dev.off()

  latexDocument <- c(
    "\\documentclass{article}",
    "\\usepackage{Sweave}",
    "%\\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>}",
    "\\begin{document}",
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    "\\begin{figure}",
    "\\includegraphics{" %_% filename %_% "-fig}",
    "  \\caption{Figure Caption}",
    "\\end{figure}",
    "\\end{document}")

  con <- file(filename %_% ".tex"); writeLines(latexDocument, con); close(con)
  system("pdflatex " %_% filename)
}

test("test1", 1)
test("test2", 0.3)

比较输出文件测试1.pdf and 测试2.pdf,我注意到在 Acrobat 或 Acrobat Reader 中查看时,后一个文档具有较重的字体。问题已经讨论过了here https://stackoverflow.com/questions/5752170/ggplot2-adding-alpha-parameter-makes-all-other-text-darker-bold-in-pdf之前,但没有解决。

我似乎无法解决这个问题,这弄乱了我用 Sweave 生成​​的报告的外观。有人对此有任何见解吗?我在 Windows 上使用 R 版本 2.13.1。


Try the pdf()带参数的函数,colormodel = "cmyk"?

require("ggplot2")
pdf("test_cmyk.pdf", colormodel = "cmyk")
ggplot(mtcars, aes(wt, mpg)) + geom_point(size = 3, alpha = 0.2) +
  opts(title = "cmyk, alpha = 0.2")
dev.off()
embedFonts("test_cmyk.pdf")

似乎比colormodel = "rgb"在我的环境中(Win XP、Adobe Acrobat 9 Pro)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ggplot2:为什么半透明+ pdflatex 会导致比普通 PDF 字体更重? 的相关文章

随机推荐