我想添加一些时间序列条形图,以显示某些位置的输出,这些位置在我的数据中具有长和纬度坐标。
我的数据结构是
name lat long 2018 2017 2016 2015 2014
A 39.90758 116.172226 505 197 683 546 777
B 39.636198 118.21615 643 722 556 460 616
C 36.609239 114.449096 532 460 337 160 135
D 39.825701 116.288499 337 932 238 146 997
E 40.217421 118.228679 277 636 811 144 777
F 40.120408 116.264347 705 566 402 230 129
G 37.92465 112.558931 411 546 260 471 879
H 40.658669 109.770433 563 281 103 929 558
我知道如何制作地图,但无法弄清楚如何在该地图上为每个位置添加时间序列条形图。
keymill <- read_xlsx("C:/R/keymill.xlsx",sheet="Sheet3")
colnames(keymill)[1] <- "mills"
keymill <- gather(keymill, year, output, -c(mills, lat, long))
keymill$output <- as.numeric(keymill$output)
keymill$year <- as.numeric(keymill$year)
keymill2 <- filter(keymill, year == 2018)
china <- map("china", plot = FALSE, xlim = c(100, 125), ylim = c(17, 45))
map.test <- ggplot()+
geom_path(data = china,
aes(long, lat, group = group),
color = '#FD9FA4', show.legend = FALSE) +
geom_point(data = keymill2,
aes(x = long, y = lat, size = output, alpha = 0.8),
show.legend = FALSE)+
geom_text_repel(data = keymill2,
aes(x = long, y = lat, label = mills),
size = 3) +
theme_bw() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(size = 15, face = "bold", hjust = 0.5),
plot.subtitle = element_text(size = 13, hjust = 0.8)) +
ggtitle(label = "Crude steel production at Chinese top mills",
subtitle = "size > 10 million tonnes")+