我寻找各种方法来通过GGPLOT2的stat_contour产生的轮廓完全填满。当前结果是这样的:如何填写轮廓充分利用stat_contour
# Generate data
library(ggplot2)
library(reshape2) # for melt
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
v <- ggplot(volcano3d, aes(x, y, z = z))
v + stat_contour(geom="polygon", aes(fill=..level..))
期望的结果可以通过手动修改代码如下来生产。
v + stat_contour(geom="polygon", aes(fill=..level..)) +
theme(panel.grid=element_blank())+ # delete grid lines
scale_x_continuous(limits=c(min(volcano3d$x),max(volcano3d$x)), expand=c(0,0))+ # set x limits
scale_y_continuous(limits=c(min(volcano3d$y),max(volcano3d$y)), expand=c(0,0))+ # set y limits
theme(panel.background=element_rect(fill="#132B43")) # color background
我的问题:有没有办法完全填满,而无需手动指定颜色或使用geom_tile()
的情节?
相关:http://stackoverflow.com/questions/25788727/filled-contour-vs-ggplot2-stat-contour – tonytonov 2015-02-12 06:52:49
据我所知,你需要扩大你的数据集手动。你的解决方案看起来更简单,所以如果你对它满意,就放手吧。 – tonytonov 2015-02-12 06:55:15
我也看过那篇文章,但geom_tile()使用小矩形,所以它不是我要找的效果。 filled.contour产生了迄今为止最好的结果,但它与多个阴谋的不兼容导致我尝试使用ggplots。我想知道是什么产生了透明区域。 – chengvt 2015-02-12 07:14:25