ways to create a map in plotly-R
library(plotly)map_data("county") %>%
+ group_by(group) %>%
+ plot_ly(x = ~long, y = ~lat) %>%
+ add_polygons() %>%
+
+ layout(
+ xaxis = list(title = "", showgrid = FALSE, showticklabels = FALSE),
+ yaxis = list(title = "", showgrid = FALSE, showticklabels = FALSE)
+ )
map_data("world", "canada") %>%
+ group_by(group) %>%
+ plot_ly(x = ~long, y = ~lat, alpha = 0.2) %>%
+ add_polygons(hoverinfo = "none", color = I("black")) %>%
+ add_markers(text = ~paste(name, "<br />", pop), hoverinfo = "text",
+ color = I("red"), data = maps::canada.cities) %>%
+ layout(showlegend = FALSE)
0 Comments