我想为经度和纬度定义的多个位置绘制点和文本标签。对于单个位置来说,它工作正常,但是我很难在geom_point
中将其扩展为一组数据。
library(ggplot2)
require(maps)
GER <- map_data("world", region = "Germany")
ggplot(GER, aes(x = long, y = lat, group = group)) +
geom_polygon(fill="lightgray", colour = "white")+
geom_point(aes(x = 13.404954, y = 52.520008), color="red")+
geom_text(aes(x = 13.404954, y = 52.520008), label = "Berlin", color = "red", nudge_y = .2)
df <- data.frame(name = c("Berlin", "Hamburg"),
long = c(13.404954, 9.993682),
lat = c(52.520008, 53.551086))
# How to do it?
ggplot(GER, aes(x = long, y = lat, group = group)) +
geom_polygon(fill="lightgray", colour = "white")+
geom_point(aes(x = df$long, y = df$lat), color="red")