任何人都可以使用ggmap(heatmap)來幫助我嗎? 我的數據:ggmap具有值的熱圖
val_Qtd <- c(34, 10, 11, 7, 55, 18, 33, 16, 16, 249)
nom_State <- c("Distrito Federal","Bahia","Ceara","Espirito Santo","Minas Gerais","Parana","Rio de Janeiro","Rio Grande do Sul","Santa Catarina","Sao Paulo")
lon <- c(-47.86447, -41.70073, -39.32062, -40.30886, -44.55503, -52.02154, -43.20940, -51.21770, -50.21886, -46.62918)
lat <- c(-15.799765, -12.579738, -5.498398, -19.183423, -18.512178, -25.252089, -22.913948, -30.034632, -27.242339, -23.543179)
ds_DadosAcessos <- data.frame(char = nom_State, lon, lat, val_Qtd)
我的情節:
library(ggmap)
img_Mapa <- get_map('Brazil', zoom = 4)
ggmap(img_Mapa, extent = "device") +
stat_density2d(data = ds_DadosAcessos,
aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") +
scale_fill_gradient(low = "green", high = "red") +
scale_alpha(range = c(0, 0.3), guide = FALSE)
顯然,熱圖使用記錄的數量calc下熱圖。但是我需要通過val_Qtd列來計算熱圖。
也許是這樣的。
幾乎沒有,我需要表現爲熱圖,但它會很好地工作。我找到了另一種方式,我會發布解決方案。 TKS! –