ggplot2:为什么Semi-Transparency + pdflatex会导致比正常的PDF字体更严重? [英] ggplot2: Why Does Semi-Transparency + pdflatex Cause Heavier-Than-Normal PDF Fonts?
问题描述
ggplot2:为什么semi-Transparency + pdflatex会导致比正常的PDF字体更重要?
ggplot2: Why Does Semi-Transparency + pdflatex Cause Heavier-Than-Normal PDF Fonts?
我遇到了一个问题,其中在R中输入pdf()
然后输入 pdflatex
-ing ggplot2图像会使与图像相同页面上的所有文本变得底气,但只有当 alpha
< 1.这是R中的一个小例子:
I've run into a problem where pdf()
ing in R and then pdflatex
-ing a ggplot2 image causes all of the text on the same page as the image to become emboldened, but only when alpha
< 1. Here's a minimal example in 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)
比较输出文件 test1.pdf 和 test2。 pdf ,我注意到后者文档在Acrobat或Acrobat Reader中查看时具有较重的字体。这个问题已经被讨论过了这里 a>之前,但没有解决。
Comparing the output files test1.pdf and test2.pdf, I notice that the latter document has heavier fonts when viewed in Acrobat or Acrobat Reader. The problem has been discussed here before, but to no resolution.
我似乎无法解决这个问题,这弄乱了我用Sweave生成的报告的外观。有没有人有任何洞察力呢?我在Windows上使用R 2.13.1版本。
I can't seem to solve the problem, which messes up the look of reports I generate with Sweave. Does anyone have any insight into it? I'm using R version 2.13.1 on Windows.
推荐答案
试试 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
XP,Adobe Acrobat 9 Pro)。
It seems to be slightly better than colormodel = "rgb"
in my environment (Win XP, Adobe Acrobat 9 Pro).
这篇关于ggplot2:为什么Semi-Transparency + pdflatex会导致比正常的PDF字体更严重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!