在ggmap上创建两个geom_tile图层

时间:2017-07-23 17:15:12

标签: r ggplot2 ggmap

我正在尝试使用geom_tile在ggmap上表示两个变量(犯罪和租金价格)。单独地,两张地图看起来都很棒。

heat_crime = ggmap(cmap) + 
        geom_tile(data = LatLonCounts_crime, aes(x = Longitude, y = Latitude, alpha = Frequency), fill="red") + 
        scale_alpha(range = c(0, 0.8))

heat_price = ggmap(cmap) + 
        geom_tile(data = mean_price_per_bedroom_per_tile, aes(x = Longitude, y = Latitude, alpha = mean_price), fill="blue") + 
        scale_alpha(range = c(0, 0.8))

heat_price

我想在同一张地图上添加两个geom_tiles。我试过这个:

heat_all = ggmap(cmap) + 
        geom_tile(data = LatLonCounts_crime, aes(x = Longitude, y = Latitude, alpha = Frequency), fill="red") + 
        scale_alpha(range = c(0, 0.8)) + 
        geom_tile(data = mean_price_per_bedroom_per_tile, aes(x = Longitude, y = Latitude, alpha = mean_price), fill="blue") + 
        scale_alpha(range = c(0, 0.8))

heat_all

但是geom_tile叠加然后将价格和犯罪变量合并为一个(当你看到图例时会变得清晰)。

如何将两个变量完全分开并在同一个ggmap中显示它们?

0 个答案:

没有答案
相关问题