R ggplot : geom_tile lines in pdf output

标签 r pdf ggplot2

我正在构建一个使用 geom_tile 的图,然后将其输出到 .pdf (使用 pdf("filename",...))。但是,当我这样做时,.pdf 结果中有细小的线条(有人说是条纹)贯穿其中。我附上了一张显示问题的图片。 Minimal example

谷歌搜索让到 this thread ,但唯一真正的建议是尝试将 size=0 传递给 geom_tile,我这样做没有任何效果。关于如何解决这些问题的任何建议?我想在论文中使用它作为图形,但它不会像这样工作。

最小代码:

require(ggplot2)
require(scales)
require(reshape)

volcano3d <- melt(volcano) 
names(volcano3d) <- c("x", "y", "z") 
 v <- ggplot(volcano3d, aes(x, y, z = z)) 

pdf("mew.pdf")
print(v + geom_tile(aes(fill=z)) + stat_contour(size=2) + scale_fill_gradient("z"))

最佳答案

发生这种情况是因为默认 colour中的瓷砖 geom_tile好像是白色的。

要解决此问题,您需要映射 colour以与 fill 相同的方式到 z .

print(v + 
  geom_tile(aes(fill=z, colour=z), size=1) + 
  stat_contour(size=2) + 
  scale_fill_gradient("z")
)

enter image description here

关于R ggplot : geom_tile lines in pdf output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10276762/

相关文章:

java - Android PdfDocument 在保存到外部存储时损坏

php - .htaccess 重定向根文件夹中的 .pdf/.doc 文件

r - 将向量绘制为条形图

r - ggplot2:在两个密度图上排列 x 限制

r - 使用 R 动画库和 Imagemagick 保存 gif 视频时出错

asp.net - 使用 Persits.PDF 在 pdf 中显示为 é 的重音字符

r - 如何在 R 中将绘图保存为黑白(无灰色像素)图像?

r - ggplot2:scale_alpha()的阈值

r - 计算二进制图像的圆度

r - Knitr:内联文本的尾随零