[英]segments of varying size on map chart with ggplot2 / ggchart
I have the following map chart我有以下 map 图表
library(dplyr)
library(ggmap)
library(ggplot2)
register_google(key = "xxx")
map5 <- get_googlemap("Zurich", zoom = 6, scale = 1, style = s)
map5 %>% ggmap
ggmap(map5)
DZ <- c(46.7985, 8.2318)
DE <- c(51.1657, 10.4515)
FR <- c(47.0260, 4.8400)
IT <- c(44.4949,11.3426)
df5 <- data.frame(rbind(DE, FR, IT)) %>% as_tibble
colnames(df5) <- c('latitude', 'longitude')
df5 <- df5 %>% select(longitude, latitude) %>% mutate(name=c('DE', 'FR', 'IT'), name2 = "DZ", lon2=DZ[2], lat2=DZ[1], route=paste(name, name2, sep='_'))
pmap <- ggmap(map5) +
geom_point(data = df5, aes(x = longitude, y = latitude, color = route))+
geom_point(aes(x = DZ[2], y = DZ[1], color = "DZ"))
#geom_line(data = data2, aes(x = lon, y = lat, group = pair))
routecols=c('orange', 'lightblue', 'green')
for (i in 1:nrow(df5)) {
pmap <- pmap + geom_segment(color = routecols[i],x= df5$longitude[i], y = df5$latitude[i], xend=df5$lon2[i], yend=df5$lat2[i])#,arrow = arrow(length = unit(0.5, "cm")))
}
pmap <- pmap +scale_color_manual(name = "", values = c('IT_DZ'='green', 'FR_DZ'='lightblue', 'DE_DZ'='orange', 'DZ'='pink'))
pmap
QUESTION : How can I take a size into account?问题:如何考虑尺寸? I'm looking for something like this, ideally varying sizes along the same line, so that the direction is clear:
我正在寻找这样的东西,理想情况下沿着同一条线改变尺寸,以便方向明确:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.