问题
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