ggplot将弯曲的段放在使用ggmap创建的地图上

时间:2016-11-10 18:47:45

标签: r ggplot2 ggmap

我正在使用以下代码中的ggmap在地图上绘制geom_segment:

rm(list=ls())
library(ggmap)
library(ggplot2)
library(grid)

data <- data.frame(point=c("One"), latitude=c(-20),longitude=c(-25), latitude_end=c(50),longitude_end=c(50),sample=c("One"))

map <- get_map(location=c(-20,-10,55,30), zoom = 3, maptype = "terrain", scale = 2)

p0 <- ggmap(map, size=c(100, 200), extent="device", legend="bottom")
p1 <- p0 +
geom_segment(data=data, aes(x=longitude, y=latitude, xend=longitude_end, yend=latitude_end), 
           colour="black") +
geom_point(data = data, aes(x =longitude, y = latitude), size=3,shape = 16)
png("plot.png")
p1
dev.off()

enter image description here

弯曲是轻微的,仔细看,你会发现它在那里(或在显示器上放一些东西),这会在添加更多线条后产生可怕的美学效果。是否可以在地图上强制使用直线?

旁注:是否也可以使用一些文本(数据$ sample)在文本末尾嵌入带有文本的插图?

0 个答案:

没有答案