服务热线
178 0020 3020
library("ggplot2")
library("maptools")
library("rgdal")
library("plyr")
china_map<-readShapePoly("bou2_4p.shp")
map <- fortify(china_map)
data <- china_map@data
data <- data.frame(dat,id=seq(0:924)-1)
head(data)
merge_data <- join(map, data, type = "full")
hebei_data <- subset(merge_data,NAME=="河北省")
ggplot(hebei_data, aes(x = long, y = lat, group = group,fill=NAME))+
geom_polygon(fill="pink")+
geom_path(colour = "grey40")+
geom_point(x=118.11,y=39.36, fill="black")+
annotate("text",x=115.50,y=39.36,label="河北省")+
annotate("text",x=118.11,y=39,label="唐山")+
ggtitle("R2-31")
library("ggplot2")
library("maptools")
library("rgdal")
library("plyr")
library("mapproj")
china_map<-readShapePoly("bou2_4p.shp")
map <- fortify(china_map)
data<-china_map@data
data2<-data.frame(data,id=seq(0:924)-1)
merge_data<-join(map,data2,type = "full")
pop<-read.csv("R2-9-1.csv")
merge_data2<-join(merge_data, pop, by = "NAME", type = "full")
mytheme<-theme(
panel.background = element_blank(),
panel.grid = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
legend.position = c(1.0,0.5))
ggplot(merge_data2, aes(x = long, y = lat, group = group,fill=pop))+
geom_polygon()+
scale_fill_gradient(low = "white",high = "red")+
geom_path(colour = "green")+
ggtitle("R2-31 中国人口信息与行政区域结合图")+mytheme
附件