ggplot2 - 添加 alpha 参数使 PDF 中的所有其他文本变暗/加粗
我注意到,当我将 alpha 参数添加到几何图形时,当输出为 PDF 时,图表上的所有文本(轴标题等)都会变暗(几乎就像它们变成粗体一样)。这似乎与实际的 alpha 值无关。它使图表变得更难看,特别是当每页有多个图表且有大量文本时。还有其他人经历过吗?
比较以下内容(可能是一个不好的例子,因为文本很少......但如果在同一屏幕上最大化并在它们之间切换,您会看到差异)
pdf(FILE_HERE1)
p <- ggplot(mtcars, aes(wt, mpg))
p = p + geom_point()
print( p )
dev.off()
pdf(FILE_HERE2)
p <- ggplot(mtcars, aes(wt, mpg))
p = p + geom_point( alpha=.2)
print( p )
dev.off()
I've noticed that when I add alpha parameter to a geom all text on the graph (axis titles, etc.) get darker (almost as if they have become bold) when output is PDF. This doesn't seem to be tied to the actual alpha value. It makes the charts a lot harder on the eyes, particularly when there are multiple charts per page with lots of text. Has anyone else experienced this?
compare the following (probably a bad example because there is little text...but if maximize on the same screen and toggle between them you'll see the difference)
pdf(FILE_HERE1)
p <- ggplot(mtcars, aes(wt, mpg))
p = p + geom_point()
print( p )
dev.off()
pdf(FILE_HERE2)
p <- ggplot(mtcars, aes(wt, mpg))
p = p + geom_point( alpha=.2)
print( p )
dev.off()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,这与 ggplot2 本身无关,而是与我们如何感知对比度有关。在这两个图中,文本都是 59% 黑色(0%=白色),在这种情况下感知的难易程度取决于对象之间的对比度。在第一个示例中,页面为 0% 黑色,背景网格为 15% 黑色,绘图标记为 100% 黑色。此处,当范围为 0-100% 黑色时,相对容易区分 59% 黑色文本。在第二张图中,您不仅必须感知绘图标记(只有 35% 黑色与 15% 黑色背景网格相比)之间的对比度,而且最暗的对象现在也只有 59% 黑色。
Well, this has nothing to do with ggplot2, per se, but how we perceive contrast. In both the plots the text is 59% black (0%=white), and ease of perception in this case comes down to the amount of contrast between the objects. In the first example, the page is 0% black, background grid is 15% black, and plot markers are 100% black. Here, it's relatively easy to distinguish 59% black text when the range is from 0-100% black. In the second plot, not only do you have to perceive the contrast between the plot markers which are only 35% black against a 15% black background grid, but your darkest object is now only 59% black.
我的发现是,这与感知无关,也许与我混合图形类型的事实有关:
R - 添加页码到 PDF
如果我在 PDF 上运行 Ghostscript,那么粗体/深色效果消失。我正在运行 Ghostscript 将字体嵌入到我的 PDF 中。一个积极的副作用是我的 PDF 大小大大缩小。我对 Ghostscript 知之甚少,所以我不确定这是否具有普遍性,或者仅仅是我使用 GhostScript 的特定方式的结果。
My finding is that this has nothing to do with perception, and perhaps something to do with the fact that I'm mixing graphics types:
R - adding page numbers to PDF
If I run ghostscript on my PDF then the bold/darker effect disappears. I'm running ghostscript to embed a font into my PDF. A positive side-effect is that my PDFs shrink in size considerably. I know very little about ghostscript, so I'm not sure if this is generalizable or simply a consequence of the specific way I'm using ghostscript.