服务热线
178 0020 3020
install.packages("maptools")
install.packages("rgdal")
library(maptools)
library(rgdal)
library(ggplot2)
library(plyr)
mytheme<-theme_classic()+theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(),axis.line=element_blank(),axis.text=element_blank(),axis.title=element_blank(),legend.position = "none")
china_map<-readShapePoly("bou2_4p.shp")
jingweidu<-china_map@data
xingzhengquyu<-data.frame(jingweidu,id=seq(0:924)-1)
china_map1<-fortify(china_map)
china_mapdata<-join(china_map1, xingzhengquyu, type = "full")
jiangsu<-subset(china_mapdata,NAME=="江苏省")
ggplot(jiangsu,aes(x=long,y=lat,group=group,fill=NAME))+geom_polygon(fill="yellow" )+geom_path(colour = "grey40")+ggtitle("R2-18-江苏-南京")+geom_point(aes(x=118.46,y=32.03),colour="red",size=2)+annotate("text",x=118.46,y=32.03,label="南京")
pop<-read.table(file.choose(),header = T,sep = ",")
china_pop<-join(china_mapdata, pop, type = "full")
ggplot(china_pop,aes(x=long,y=lat,group=group,fill=pop))+geom_polygon(colour="green")+scale_fill_gradient(low="white",high="red")+coord_map("polyconic")+ggtitle("R2-18")
附件