There are a few ways to create a map in plotly-R

 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)
+ )
www.r-languagestatistics.co
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)
www.r-languagestatistics.co


Reactions

Post a Comment

0 Comments