0
`dput(head(vert.cord))
structure(list(name = c("2994", "2996", "2997", "2999", "3000",
"3001"), Latitude = c(23.077242, 19.862728, 19.088686, 23.287828,
15.859286, 22.336164), Longitude = c(72.63465, 75.398114, 72.867919,
69.670147, 74.618292, 73.226289), node.degree = c(18, 4, 86,
2, 2, 4)), .Names = c("name", "Latitude", "Longitude", "node.degree"
), row.names = c(NA, 6L), class = "data.frame")`
`dput(head(Indian_new_routes))
structure(list(V1 = c("2994", "2994", "2994", "2994", "2994",
"2994"), V2 = c("2997", "3007", "3017", "3043", "3093", "3098"
), weight = c(2653.62642910095, 861.186965956404, 1030.6558395446,
3245.152405393, 4531.03569783294, 524.579803792743), dist = c(442.271071516825,
861.186965956404, 515.327919772298, 1622.5762026965, 755.17261630549,
524.579803792743), dist.inv = c(0.00226105676903165, 0.00116118803410992,
0.00194051197622255, 0.000616303874257576, 0.001324200558135,
0.00190628764731303), dist.inv.weight = c(0.000376842794838609,
0.00116118803410992, 0.000970255988111277, 0.000308151937128788,
0.0002207000930225, 0.00190628764731303), color = c("red", "red",
"red", "red", "red", "red"), From.lat = c(23.077242, 23.077242,
23.077242, 23.077242, 23.077242, 23.077242), From.lon = c(72.63465,
72.63465, 72.63465, 72.63465, 72.63465, 72.63465), To.lat = c(19.088686,
15.380833, 18.582111, 22.654739, 28.5665, 26.824192), To.lon = c(72.867919,
73.831422, 73.919697, 88.446722, 77.103088, 75.812161)), .Names = c("V1",
"V2", "weight", "dist", "dist.inv", "dist.inv.weight", "color",
"From.lat", "From.lon", "To.lat", "To.lon"), row.names = c(NA,
6L), class = "data.frame")`
我想創建一個機場網絡與節點作爲某些城市有拉特,長和邊緣連接兩個不同的城市。我可以得到網絡,但我想要一些不同顏色的邊緣。我在Indian_new_routes數據框中有一個顏色屬性。但由此產生的新地圖以相同的顏色顯示所有邊緣。任何幫助都感激不盡。積極add_segments不同顏色
geo <- list(
scope = 'asia',
projection = list(type = 'natural earth'),
showland = TRUE,
landcolor = toRGB("gray95"),
countrycolor = toRGB("gray80")
)
p <- plot_geo(locationmode = 'INDIA') %>%
add_markers(
data = vert.cord, x = ~Longitude, y = ~Latitude, text = ~name,
size = ~node.degree, hoverinfo = "text", alpha = 0.5, color = I("black")
) %>%
add_segments(
data = Indian_new_routes,
x = ~From.lon, xend = ~To.lon,
y = ~From.lat, yend = ~To.lat,
alpha = 0.3, size = I(1), hoverinfo = "none", color = ~color
) %>%
layout(
title = 'Jan. 2015 Indian Domestic flight paths<br>(Hover for airport names)',
geo = geo, showlegend = FALSE, height=800
)
我已經編輯我的問題,和所附的vert.cord和Indian_new_routes數據集。請看一看。 – deepAgrawal
我已經添加了上述格式的數據集。 – deepAgrawal