服务热线
178 0020 3020
library("ggplot2") library("maptools") library("rgdal") library("plyr") china_map<-readShapePoly("E:/R/R9/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") hunan_data <- subset(merge_data,NAME=="湖南省") print(hunan_data) ggplot(hunan_data, aes(x = long, y = lat, group = group,fill=NAME) )+ geom_polygon(fill="pink")+ geom_path(colour = "grey40")+ geom_point(x=111.28,y=27.14, fill="black")+ annotate("text",x=111.5,y=28,label="湖南省")+ annotate("text",x=111.28,y=26.8,label="邵阳")+ ggtitle("R2-02")
library("ggplot2") library("maptools") library("rgdal") library("plyr") library("mapproj") china_map<-readShapePoly("E:/R/R9/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("E:/R/R9/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-02 中国人口信息与行政区域结合图")+mytheme
附件