R2-12-map

pcr狗 2018-01-01 17:04:10 阅读: 1005

#设置主题

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


library(maptools)

library(rgdal)

china_map<-readShapePoly("bou2_4p.shp")

x<-china_map@data

xs<-data.frame(x,id=seq(0:924)-1)

library(ggplot2)

china_map1<-fortify(china_map) #转化为数据框

library(plyr)

china_mapdata<-join(china_map1, xs, type = "full") #合并两个数据框


#区域地图

hebei<-subset(china_mapdata,NAME=="河北省")

ggplot(hebei, aes(x = long, y = lat, group = group,fill=NAME))+

  geom_polygon(fill="purple")+

  coord_map("polyconic") +

  ggtitle("R2-12-河北省-承德")+

  geom_path(colour="grey")+

  geom_point(x=117.71,y=40.57,size=2,color="gold")+

  annotate("text",x=118.5,y=40.57,color="gold",label="承德市")+

  mytheme

chengde.png


#pop

pop<-read.table("R2-9-1.csv",header = T,sep = ",")

china_pop<-join(china_mapdata, pop, type = "full")# all rows in x with matching columns in y, then the rows of y that don't match x.

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

  mytheme

china.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

微信服务号