R2-31-第九期地图绘图

小伊伊 2018-01-02 22:36:05 阅读: 1121

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")

zjy-2.png

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

zjy-1.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号