R2-28 第九次作业

探花1号 2017-12-30 19:58:30 阅读: 1225

作业1

> library(maptools)

> library(ggplot2)

> library(plyr)

> library(rgdal)

>mytheme<-theme( panel.background=element_blank(),panel.grid=element_blank(),axis.text=element_blank(),axis.ticks=element_blank(),axis.title=element_blank(),legend.position = "none")

> setwd("C:\\Users\\LM\\Desktop\\地图")

> china_map<-readShapePoly("bou2_4p.shp")

> x<-china_map@data

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

> china_map1<-fortify(china_map)

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

> guangdong<-subset(china_mapdata,NAME=="广东省")

>ggplot(guangdong,aes(x=long,y=lat,group=group,fill=NAME))+geom_polygon(fill="yellow" )+geom_path(colour = "grey40")+ggtitle("R2-28-广东-清远")

>p<-ggplot(guangdong,aes(x=long,y=lat,group=group,fill=NAME))+geom_polygon(fill="yellow" )+geom_path(colour = "grey40")+ggtitle("R2-28-广东-清远")

> p+geom_text(mapping = aes(x=113.37,y=24.50,label=NAME),color="red",cex=6)

> h<- p+geom_text(mapping = aes(x=113.37,y=24.50,label=NAME),color="red",cex=6)

> h+geom_point(aes(x=113.14,y=23.08),colour="red",size=4,pch=19)

> w<-h+geom_point(aes(x=113.14,y=23.08),colour="red",size=4,pch=19)

> w+geom_point(aes(x=113.01,y=23.42),colour="red",size=2)

> a<-w+geom_point(aes(x=113.01,y=23.42),colour="red",size=2)

> a+annotate("text",x=113.34,y=22.88,label="广州")

> q<-a+annotate("text",x=113.34,y=22.88,label="广州")

> q+annotate("text",x=113.22,y=23.62,label="清远")

>z<-q+annotate("text",x=113.22,y=23.62,label="清远")

> install.packages("mapproj")

> library(mapproj)

> z+coord_map("polyconic")+mytheme

作业2

>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(0.9,0.4))

> data<-read.csv(file.choose())

> mydata<-as.data.frame(data)

> pop<-join(china_mapdata, mydata, type = "full")

>ggplot(pop,aes(x=long,y=lat,group=group,fill=pop))+geom_polygon()+coord_map("polyconic")+scale_fill_gradient(low="white",high="red")+geom_path(colour = "yellow")+ggtitle("R2-28")+mytheme

>p<-ggplot(pop,aes(x=long,y=lat,group=group,fill=pop))+geom_polygon()+coord_map("polyconic")+scale_fill_gradient(low="white",high="red")+geom_path(colour = "yellow")+ggtitle("R2-28")+mytheme


 
邀请讨论

附件

{{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

微信服务号