我练习“传单”,然后尝试将此地图更改为传单地图。 数据和代码来自https://www.kaggle.com/jonathanbouchet/airlines-route-tracker/report
我当前的输出是:
相关代码为:
世界地图代码:
countries_map <- map_data("world")
world_map <- ggplot() +
geom_map(data = countries_map,
map = countries_map,
aes(x = long, y = lat, map_id = region, group = group),
fill = "light blue", color = "black", size = 0.1)
用于在地图上显示输出的代码:
routes$num_aircraft <- sapply(routes$equipment,
function(x) length(strsplit(x, " ")[[1]]))
routes_7_aircrafts <- routes %>% dplyr::filter(num_aircraft == 7)
routes_8_aircrafts <- routes %>% dplyr::filter(num_aircraft == 8)
routes_9_aircrafts <- routes %>% dplyr::filter(num_aircraft == 9)
routes_7 <- makeNetwork(routes_7_aircrafts, 'more than 6')
routes_8 <- makeNetwork(routes_8_aircrafts, 'more than 7')
routes_9 <- makeNetwork(routes_9_aircrafts, 'more than 8')
tot_routes <- rbind(routes_7, routes_8, routes_9)
world_map +
geom_curve(data = tot_routes,
aes(x = airport.start.long, y = airport.start.lat, xend = airport.end.long,
yend = airport.end.lat, color = airline.name),
curvature = 0.2, arrow = arrow(length = unit(0.005, "npc")),
alpha = 1, size = 1.5) +
theme_fivethirtyeight() +
theme(
legend.position = c(.85, 1.075),
panel.grid.major = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(face = "bold", hjust = .012, vjust = .8,
colour = "#3C3C3C", size = 20),
plot.subtitle = element_text(size = 10, hjust = 0, face = "italic", color = "black")) +
labs(
title = "Busiest Routes in the World",
subtitle = "Shown are the routes used by 7 or more different aircrafts") +
scale_color_manual(name = "", values = c("Blue" ,"red" ,"green"))
我尝试使用传单地图创建相同的输出,如下所示:
有什么想法吗?谢谢!