Adding color scale using add_heatmap in googleway

北战南征 提交于 2020-01-06 04:51:11

问题


I am creating heatmap using googleway. For example, for the tram_route example given in the help of ?add_heatmap, how can I add a color scale so that the reader knows what is the number associated with that color?

Thank you.


回答1:


Note:

As of 2017-10-04 the legend is still in development and is subject to change, and may not be 100% fully functional yet.

Installation

devtools::install_github("SymbolixAU/googleway")
library(googleway)

Examples

set.seed(20170417)
df <- tram_route
df$weight <- sample(1:10, size = nrow(df), replace = T)

google_map(key = map_key, data = df) %>%
  add_heatmap(lat = "shape_pt_lat", lon = "shape_pt_lon", weight = "weight",
              option_radius = 0.001, legend = T)

## specifying different colour gradient
option_gradient <- c('orange', 'blue', 'mediumpurple4', 'snow4', 'thistle1')

google_map(key = map_key, data = df) %>%
 add_heatmap(lat = "shape_pt_lat", lon = "shape_pt_lon", weight = "weight",
              option_radius = 0.001, option_gradient = option_gradient, legend = T)



来源:https://stackoverflow.com/questions/46547753/adding-color-scale-using-add-heatmap-in-googleway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!