我了解当我们使用plot_geo
时,我们可以在地图中添加标记/片段
以下是我生成的地图示例代码:
library(plotly)
library(dplyr)
flights <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv')
flights$id <- seq_len(nrow(flights))
geo <- list(
scope = 'world',
projection = list(type = 'equirectangular'), #equirectangular, natural earth, orthographic, kavrayskiy7, miller
showland = TRUE,
showcountries = TRUE,
landcolor = toRGB("gray95"),
countrycolor = toRGB("gray80")
)
p <- plot_geo(
locationmode = 'country-names') %>%
layout(geo = geo) %>%
add_segments(
data = flights,
x = ~start_lon, xend = ~end_lon,
y = ~start_lat, yend = ~end_lat,
alpha = 0.3,
color = ~airport1,
size = I(2.5),
hoverinfo = "none"
)
有没有办法添加箭头而不是像ggnetworkmap
或ggmap
这样的线来显示移动/方向?
看看我生成的情节,很难说出箭头的移动方向。如果这是不可能的,有人可能建议采用不同的方式来显示方向吗?