【发布时间】:2018-07-25 02:52:02
【问题描述】:
我在地图上绘制浓度数据,我的数据如下所示:
Lat Long Conc Colour
-33.90624 151.2237 10.0 #4393C3
-33.92404 151.2280 12.95 #92C5DE
-33.92384 151.2275 14.0 #D1E5F0
在地图上绘制使用:
map <- ggmap(map)+
scale_x_continuous(limits = c(151.220, 151.230), expand = c(0, 0)) +
scale_y_continuous(limits = c(-33.927, -33.902), expand = c(0, 0))
map +
geom_point(data = df_avg, aes(x = df_avg$Long, y = df_avg$Lat),
col = df_avg$Colour, cex = 4.2) +
ggtitle(paste0("PM2.5 (ug/m3)", " ", title_start," - ", title_end))
我使用的色阶是:(“RdBu”RColorBrewer 调色板)
"#67001F" "#B2182B" "#D6604D" "#F4A582" "#FDDBC7"
"#F7F7F7" "#D1E5F0" "#92C5DE" "#4393C3" "#2166AC" "#053061"
我想在我的地图一侧添加一个带有离散方块的标记颜色轴。谁能帮我这个?
我附上了我所想的a picture - 这是取自R ggplot2 discrete colour palette for gradient map(这个问题对我没有帮助,因为我正在使用ggmap)
谢谢!
【问题讨论】:
-
我建议让
ggplot()为你做美学映射:因为你自己做了映射(我假设某种Conc -> Colour映射在这里?)ggplot2 无法自动为您生成图例。 -
看scale_fill_manual()
标签: r ggplot2 plot color-scheme ggmap