服务热线
178 0020 3020
setwd("E:/bioinformatics/fanzhimin")
install.packages("maptools")
install.packages("rgdal")
library(maptools)
library(rgdal)
library(ggplot2)
library(plyr)
D <- 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")
china_map<-readShapePoly("bou2_4p.shp")
data1<-china_map@data
data2<-data.frame(data1,id=seq(0:924)-1)
china_map1<-fortify(china_map)
china_mapdata<-join(china_map1, data2, type = "full")
P<-subset(china_mapdata,NAME=="广东省")
ggplot(P,aes(x=long,y=lat,group=group,fill=NAME))+geom_polygon(fill="yellow" )+geom_path(colour = "grey40")+ggtitle("R2-36-广东-汕头")+geom_text(mapping = aes(x=116.7,y=25.5,label=NAME),color="red",cex=6)+geom_point(aes(x=116.17,y=23.97),colour="red",size=4,pch=19)+annotate("text",x=116.15,y=24,color="red",label="汕头")+D
install.packages("mapproj")
library(mapproj)
P<-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))
population<-read.csv("R2-9-1.csv")
mydata<-as.data.frame(population)
pop<-join(china_mapdata, mydata, type = "full")
ggplot(pop,aes(x=long,y=lat,group=group,fill=pop))+geom_polygon()+coord_map("polyconic")+geom_polygon(colour="green")+scale_fill_gradient(low="white",high="red") +ggtitle("R2-36")+P
附件