Hello to all
Im trying to plot some locations extracted from several datasets onto a US map. I already tried the “split” parameter but this only works when i have a single dataset and i can segregate by one column. Since i have 3 different datasets, is it possible to use all of the 3 datasets at the same time on one single us map and differentiate by color? due to the original dataset construction, i cannot filter but one single column, therefore i need to use the 3 separate datasets
this is what i have so far. as you can see, this creates 3 different us maps, each one based on a different dataset
thanks!
tesla_locations_chargers <- subset(tesla_locations, charger == "Yes")
tesla_locations_chargers <- subset(tesla_locations_chargers, country == "United States")
tesla_locations_stores <- subset(tesla_locations, store == "Yes")
tesla_locations_stores <- subset(tesla_locations_stores, country == "United States")
tesla_locations_service <- subset(tesla_locations, service == "Yes")
tesla_locations_service <- subset(tesla_locations_service, country == "United States")
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showland = TRUE,
landcolor = toRGB("gray95"),
subunitcolor = toRGB("gray85"),
countrycolor = toRGB("gray85"),
countrywidth = 0.5,
subunitwidth = 0.5
)
#plotting stores on us
fig1 = plot_geo(tesla_locations_stores,
lat = ~latitude,
lon = ~longitude
#split = ~charger
)
fig1 <- fig1 %>% add_markers(text = ~paste(title,city, sub_region,sep = "<br />"),
symbol = I("square"),
size = I(8),
hoverinfo = "text"
)
fig1 <- fig1 %>% layout(title = 'Tesla stores in the US', geo = g)
fig1
#plotting chargers network on us
fig2 = plot_geo(tesla_locations_chargers,
lat = ~latitude,
lon = ~longitude
#split = ~charger
)
fig2 <- fig2 %>% add_markers(text = ~paste(title,city, sub_region,sep = "<br />"),
symbol = I("square"),
size = I(8),
hoverinfo = "text"
)
fig2 <- fig2 %>% layout(title = 'Tesla chargers in the US', geo = g)
fig2
#plotting service network on us
fig3 = plot_geo(tesla_locations_service,
lat = ~latitude,
lon = ~longitude
#split = ~charger
)
fig3 <- fig3 %>% add_markers(text = ~paste(title,city, sub_region,sep = "<br />"),
symbol = I("square"),
size = I(8),
hoverinfo = "text"
)
fig3 <- fig3 %>% layout(title = 'Tesla service stations in the US', geo = g)
fig3