ggplot2:为什么半透明+ pdflatex导致比正常更重要的PDF字体?

pri*_*ian 10 r ggplot2

ggplot2:为什么半透明+ pdflatex导致比正常更重要的PDF字体?

我遇到了一个问题,其中pdf()在R中然后pdflatex-ing ggplot2图像导致与图像在同一页面上的所有文本变得粗壮,但仅在alpha<1 时.这是R中的最小示例:

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)
Run Code Online (Sandbox Code Playgroud)

比较输出文件test1.pdftest2.pdf,我注意到在Acrobat或Acrobat Reader中查看后一个文档有较重的字体.这个问题已经讨论过这里之前,但都没有解决.

我似乎无法解决这个问题,这会混淆我用Sweave生成的报告的外观.有没有人对它有任何见解?我在Windows上使用R版本2.13.1.

Tri*_*ou. 2

尝试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")
Run Code Online (Sandbox Code Playgroud)

看起来比colormodel = "rgb"我的环境(Win XP、Adobe Acrobat 9 Pro)稍好一些。

在此输入图像描述