Hi, the R code on the Plotly website for scatter plots on maps is incorrect. This code does not reproduce the hover text shown on the map. Only the points are plotted on the map, with no hover functionality. Is there a workaround for this, or better code maybe to achieve the same outcome?
library(plotly)
df <- read.csv(‘https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv’)
geo styling
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
)
p <- plot_geo(df, lat = ~lat, lon = ~long) %>%
add_markers(
text = ~paste(airport, city, state, paste(“Arrivals:”, cnt), sep = “
”),
color = ~cnt, symbol = I(“square”), size = I(8), hoverinfo = “text”
) %>%
colorbar(title = “Incoming flights
February 2011”) %>%
layout(
title = ‘Most trafficked US airports
(Hover for airport)’, geo = g
)