服务热线
178 0020 3020
##R2-09 MAP
install.packages("sp") library("ggplot2") library("maptools") mytheme <- theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), #隐藏网格线 legend.position = "none", #移除图例,参考R数据可视化手册181-186页,关于移除图例的方法。 plot.caption = element_text(face = "bold.italic") ) china_map <-readShapePoly("bou2_4p.shp") china_map2 <- china_map@data xs<-data.frame(china_map2,id=seq(0:924)-1) china_map1 <-fortify(china_map) china_mapdata<-join(china_map1, xs, type = "full") gansu <- subset(china_mapdata,AREA == 41.508) ggplot(gansu, aes(x = long, y = lat, group = group,fill=NAME)) + geom_polygon(fill="pink") + geom_path(colour = "grey40") + geom_point(x=107.742429,y = 35.543212) + annotate("text",x=108,y = 34.5,label="My Hometown") + annotate("text",x=105,y=32,label="GANSU",size=4,colour="black") + xlim(90,110) + ylim(31,43) + ggtitle("R2-05-GANSU") + mytheme
作业二:
mac 中文问题还没有解决,导致全是乱码,而且目前竟然连数据也没法读入。。。
附件