我运行了这段代码:
columbus <- get_map('columbus', zoom = 11)
ColumbusMap <- ggmap(columbus, extent = "device", legend = "topleft")
Warning message:
`panel.margin` is deprecated. Please use `panel.spacing` property instead
ColumbusMap +
stat_density2d(aes(x = longitude, y = latitude,
fill = ..level..,
alpha = ..level..),
size = 2, bins = 4, data=all[all$year==2006,], geom = "polygon" ) +
scale_fill_gradient(low="red", high="royalblue")
我有两个传说,一个灰色和一个颜色,我只想要一种颜色。
答案 0 :(得分:0)
尝试在代码末尾添加guides(alpha=FALSE)
,如下所示:
ColumbusMap +
stat_density2d(aes(x = longitude, y = latitude,
fill = ..level..,
alpha = ..level..),
size = 2, bins = 4, data=all[all$year==2006,], geom = "polygon" ) +
scale_fill_gradient(low="red", high="royalblue") +
guides(alpha=FALSE)
无论何时在aes()中添加填充,alpha或颜色,都会得到一个图例。幸运的是,通过使用如图所示的指南(),这些很容易删除。