R-M*_*Hup 3 r ggplot2 density-plot
导出为PDF后,我不断获得这些白线.它们在R中不可见,但一旦导出就会显示.这似乎也是一个特定于mac的问题.导出到tiff时不会出现问题.
数据:
> dput(head(newdemodf1,10))
structure(list(x = c(21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L), y = c(27L, 26L, 27L, 28L, 29L, 30L, 31L, 34L, 35L,
36L), totaltime = c(0.0499999523162842, 0.0499999523162842, 0.379999876022339,
0.0500004291534424, 0.0299999713897705, 0.109999895095825, 0.0499999523162842,
0.0299999713897705, 0.0500001907348633, 0.0299999713897705)), .Names = c("x",
"y", "totaltime"), row.names = c(NA, 10L), class = "data.frame")
library(ggplot2)
library(RColorBrewer)
ggplot(newdemodf1) +
stat_density2d(aes(x=x, y=y, z=totaltime, fill = ..density..),
geom="tile", contour = FALSE) +
scale_fill_gradientn(colours=cols)
Run Code Online (Sandbox Code Playgroud)
然后我导出到PDF导入adobe illustrator.但是,我得到的情节如下:

如何删除白线?这是否涉及平滑颜色?或以某种方式更换瓷砖?缺少x,y组合?任何帮助赞赏.
那些白线通常是你正在使用的pdf浏览器的人工制品; 放大或缩小时,它们似乎可能会移动.
您可以尝试"光栅"而不是"平铺",它似乎与Illustrator更好地工作.

set.seed(4393)
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
g1 <- ggplot(dsmall, aes(carat, price)) +
stat_density2d(geom="tile", aes(fill = ..density..), contour = FALSE)
g2 <- ggplot(dsmall, aes(carat, price)) +
stat_density2d(geom="raster", aes(fill = ..density..), contour = FALSE)
ggsave("g1.pdf",g1)
ggsave("g2.pdf",g2)
Run Code Online (Sandbox Code Playgroud)