我有一个数据帧包含名为ID,经度(LON),纬度(LAT)的变量,你可以download from here . 我使用 ggplot2
包使用以下代码在相同颜色的国家/地区 Map 上绘制了一些经度 - 纬度:
library(ggplot2)
library(raster)
read.csv("station.csv")
skorea<- getData("GADM", country= "KOR", level=1)
plot(skorea)
skorea<- fortify(skorea)
ggplot()+
geom_map(data= skorea, map= skorea, aes(x=long,y=lat,map_id=id,group=group),
fill=NA, colour="black") +
geom_point(data=station, aes(x=LON, y=LAT),
colour= "red", alpha=1,na.rm=T) +
scale_size(range=c(2,7))+
labs(title= "coordinate data of seoul",
x="Longitude", y= "Latitude")+
theme(title= element_text(hjust = 0.5,vjust = 1,face= c("bold")))
我得到了以下情节
现在我希望其中一些点将根据其ID在不同颜色的 Map 上绘制 . 例如,我希望这些ID(111141,111142,111241,111281,111301,131141,131144,131161)将为蓝色,其余ID将保持红色 . 我怎样才能做到这一点?
1 回答
也许: