R2-29 第九期作业-地图绘制

CISO 2017-12-31 20:24:09 阅读: 1072

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

map1.pngmap2.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

微信服务号