服务热线
178 0020 3020
#load packages
library(maptools)
library(plyr)
library(ggplot2)
#data preprocessing
china_map<-readShapePoly(file.choose())
map <- fortify(china_map)
dat<-china_map@data
dat2 <- data.frame(dat,id=seq(0:924)-1)
merge_dat <- join(map, dat2, type = "full")
shanxi_dat<-subset(merge_dat,NAME=="陕西省")
# plotting 1
mytheme=theme_bw() #+theme(panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),legend.position = "none")
p<-ggplot(shanxi_dat, aes(x = long, y = lat, group = group,fill=NAME))+geom_polygon(fill="pink")+geom_path(colour = "grey40")+geom_point(x=108.95,y=34.26667,fill="red")+annotate("text",x=109,y=34,label="CC's location: Xi'an")
p+mytheme+ggtitle("R2-29 CC")
# plotting 2
pop<-read.csv(file.choose())
merge_dat2 <- join(merge_dat, pop, by = "NAME", type = "full")
p<-ggplot(merge_dat2, aes(x = long, y = lat, group = group,fill=pop))+geom_polygon( )+scale_fill_gradient(low = "white",high = "red")+geom_path(colour = "green")
p+mytheme+ggtitle("R2-29 CC")
附件