Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Blank output on viewer for Line on Map

Hi,

I am extremely new to plotly in R Studio and trying to replicate the Line on Map graph in Plotly website. However, I am changing nothing and just running it. I am getting a blank output in the viewer.

Not sure what to look out for. Thanks a lot.

Code:
library(plotly)
library(dplyr)
library(ggplot2)

airport locations

air <- read.csv(‘https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv’)

flights between airports

flights <- read.csv(‘https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv’)
flights$id <- seq_len(nrow(flights))

map projection

geo <- list(
scope = ‘north america’,
projection = list(type = ‘azimuthal equal area’),
showland = TRUE,
landcolor = toRGB(“gray95”),
countrycolor = toRGB(“gray80”)
)

p <- plot_geo(locationmode = ‘USA-states’, color = I(“red”)) %>%
add_markers(
data = air, x = ~long, y = ~lat, text = ~airport,
size = ~cnt, hoverinfo = “text”, alpha = 0.5
) %>%
add_segments(
data = group_by(flights, id),
x = ~start_lon, xend = ~end_lon,
y = ~start_lat, yend = ~end_lat,
alpha = 0.3, size = I(1), hoverinfo = “none”
) %>%
layout(
title = ‘Feb. 2011 American Airline flight paths
(Hover for airport names)’,
geo = geo, showlegend = FALSE
)

p

Hey @sambitnandi.ju

could you try opening this in an external browser (as opposed to the viewer) to see if it works.

Also, are you using windows or mac?

Yup that’s what I am doing now. The external browser thing is working gperfect