R2-30第九次作业 地图

土貉 2017-12-29 16:50:30 阅读: 1178

library(maptools)

library(ggplot2)

china_map=readShapePoly("C:/Documents and Settings/Administrator/桌面/s/r/第九次作业/R2-9-地图绘图3/bou2_4p.shp")

china_map1<-fortify(china_map)

x<-china_map@data

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

library("plyr")

china_map_data <- join(china_map1, xs, type = "full")

hunan<-subset(china_map_data,NAME=="湖南省")

 

mymap1<gplot(hunan,aes(x=long,y=lat,group=group,fill=NAME))+geom_polygon(fill="beige")+geom_path(colour="grey40")+geom_point(x=112.58,y=28.11,fill="black")+annotate("text",x=112.7,y=28,label="长沙市")+annotate("text",x=111,y=29,label="湖南省",size=8,colour="red")+ggtitle("R2-30-湖南省-长沙市")

 

mytheme<- theme(panel.grid = element_blank(), panel.background = element_blank(),axis.text = element_blank(),axis.ticks = element_blank(),axis.title = element_blank())

 

mymap1+mytheme

001.png


pop<-read.csv(file.choose())

china_data<-join(china_map_data,pop,type="full")

 

mytheme2<- theme(panel.grid = element_blank(), panel.background = element_blank(),axis.text = element_blank(),axis.ticks = element_blank(),axis.title = element_blank(),legend.position = c(0.9,0.3))

 

mymap2<-ggplot(china_data,aes(x=long,y=lat,group=group,fill=pop))+geom_polygon()+scale_fill_gradient(low="white",high = "red")+geom_path(colour = "green")+coord_map("polyconic")+ggtitle("R2-30")

mymap2+mytheme2

002.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-2025 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号