Saturday, January 5, 2019

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


No comments:

Post a Comment

Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...