The R language draws maps, which are often used in data analysis and can achieve very good results, and this section provides examples of how to use the R language tools to draw the ideal map.
Examples of this section run smoothly under the R version 2.15.3 release, and other versions are pending.
The code is as follows: The first small example
# load the appropriate package, read the data, and then draw. Library (maptools), library (Ggplot2), China_map<-readshapepoly ("d://map//bou2_ 4p.shp", Proj4string=crs ("+proj=longlat +ellps=clrk66")); Plot (china_map);
Use Ggplot to draw below.
Ggplot (China_map, AES (x = long, y = lat, group = group)) + "beige") + "grey40");
Draw a better-looking map, how!
X<[email protected];#S4 class data with @ Fetch subsetXs<-data.frame (X,id=seq (0:924)-1);#Library (GGPLOT2)China_map1<-fortify (CHINA_MAP);#Convert to Data frame#There is no administrative area information Ah, this requires the front of the data frame XS. library (PLYR); China_mapdata<-join (CHINA_MAP1, xs, type =" Full");#merging two data frames#Use this new data frame to draw a map of ChinaGgplot (China_mapdata, AES (x = long, y = lat, group = group,fill=name)) +geom_polygon () +geom_path (colour ="grey40")+scale_fill_manual (Values=colours (), guide=false);
and draw a map of the city's regional type.
Zhejiang<-subset (china_mapdata,name=="Zhejiang province"); Ggplot (Zhejiang, AES (x= long, y = lat, group = group,fill=name) +Geom_polygon (Fill="Beige")+Geom_path (Colour="grey40")+Ggtitle ("Zhejiang Province, P.R. China")+geom_point (x=120.12,y=30.16,fill=false) +Annotate ("text", x=118.3,y=30,label="Hangzhou City");
Focus Point:
⊙ above is only introduce several kinds of drawing method. In addition, there are more map functions, you can look for friends. For specific parameters and corresponding indicators in the map, you can use R to bring your own Help document to view.
Transferred from: http://mp.weixin.qq.com/s?__biz=MzA3NDUxMjYzMA==&mid=209747952&idx=2&sn= 72725a5801c0b1c14a7da6cc7e68719c#rd
Every R point: All kinds of painting maps, all knowledge points, 90% people do not know! Go