【发布时间】:2019-06-20 20:28:37
【问题描述】:
我有一个包含三列的数据框:城市名称、经度、纬度。使用 ggplot 我正在尝试使用经度和纬度作为坐标来可视化数据,这些坐标代表给定的城市。我还想用城市名称标记每个点。不幸的是,比例不太正确,所以点被映射在正确的位置。
数据框的示例数据:
city_name <- c("Berlin", "Brussels", "Paris")
longitude <- c("13.405", "4.3517", "2.3522")
latitude <- c("52.52", "50.8503", "48.8566")
df <- data.frame(city_name, longitude, latitude)
我正在使用 ggplot2。
mapWorld <- borders("world", colour="gray50", fill="gray50") # create a layer of borders
ggplot(df, aes(x= longitude, y= latitude, label=Name))+
geom_point() +geom_text(aes(label=city_name),hjust=0, vjust=0) + mapWorld
当前结果: https://imgur.com/K3RvqTm
预期的结果是将坐标映射到它们的正确位置。
提前谢谢大家!
【问题讨论】:
标签: r ggplot2 visualization