淡色图例 ggplot2

5

我正在尝试使用ggplot2中的新指南系统:

require(devtools)    
dev_mode()   
install_github("ggplot2")
require(ggplot2)

require(reshape2)
p <- ggplot(melt(outer(1:4, 1:4)), aes(x=Var1, y=Var2)) + geom_tile(aes(fill=value))
p + guides(fill = guide_colorbar())

然而这个图例看起来有点模糊(不像我见过的其他例子): enter image description here

我做错了什么?

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] reshape2_1.2.1  ggplot2_0.9.0   devtools_0.6    gridSVG_0.8-1   proto_0.3-9.2   rgeos_0.2-3     stringr_0.6     gpclib_1.5-1   
 [9] maptools_0.8-14 lattice_0.20-0  sp_0.9-95       foreign_0.8-49 

loaded via a namespace (and not attached):
 [1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.1       MASS_7.3-17        memoise_0.1        munsell_0.3       
 [7] plyr_1.7.1         RColorBrewer_1.0-5 RCurl_1.91-1       scales_0.2.0       tools_2.14.1

1
+1 对问题的非常清晰的描述。 - Maiasaura
不确定,但我认为这可能会在光栅和某些图形设备的组合下发生。guide_colorbar(raster = FALSE) 会发生什么? - kohske
使用 raster = FALSE 可以去除这种模糊效果,但是图例之间会有更多的灰色水平线(在刻度之间),并且看起来不太美观。 - EDi
当我将它导出为PDF格式时,一切看起来都很好,所以这只是在显示窗口中出现的问题。 - EDi
谢谢。所以这个问题是在某个设备上绘制光栅图的问题。 - kohske
1个回答

4
看起来稳定版的 ggplot2_0.9.0reshape2_1.2.1 是可以使用的。如果有 Bug 可以在这里报告

由 ggplot 0.9.0 生成


2
谢谢您的帖子。我刚刚在shell中运行了代码,一切看起来都很正常。所以这似乎是一个RStudio的bug - 很抱歉没提到过,因为没有考虑到这个问题。 - EDi
1
是的,我可以确认这在RStudio 0.95.261中发生,但不会在shell中发生。 - jbaums
1
我已经报告了这个问题(http://support.rstudio.org/help/discussions/problems/1773-problem-using-ggplot2_090-and-rstudio)。 - EDi
@EDi - 你怎么样?不如在这个答案上打勾,将其接受为答案? - Spacedman
仅在Linux上观察到。将在下一个RStudio每日构建版本中修复(rstudio-0.96.40-amd64)。感谢大家和RStudio团队! - EDi
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接