Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Plot_geo markers and segments to unspecified point

I am making some maps on plotly with the flight paths/lines and i recently updated such things as the java version i was utilizing and i got the following map…as you can tell it is in correct. Every point is connecting to a second point somewhere in the atlantic. Plotly version 4.5.6 and 4.5.2.

library(plotly)

lat1 <- runif(10, 40,50)
lat2 <- runif(10, 40,50)
long1 <- runif(10, 40,50)
long2 <- runif(10, 40,50)

df <- as.data.frame(lat1)
df <- cbind(df, lat2, long1, long2)

plot_geo(locationmode = 'USA-states')  %>%
  add_markers(data = df, x = ~long1, y = ~lat1, color = I("red")) %>% 
  add_markers(data = df, x = ~long2, y = ~lat2, color = I("blue")) %>% 
  add_segments(
    data = df,name = "Paths",
    x = ~long1, xend = ~long2,
    y = ~lat1, yend = ~lat2,
    alpha = 0.3, size = I(3), hoverinfo = 'none'
  )

Output: