Two-dimensional pie chart
650) this.width=650; "title=" QQ picture 20150430120006.png "alt=" wkiom1vbqw3borujaaemoy6dl5g855.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/30/wkiom1vbqw3borujaaemoy6dl5g855.jpg "/>
The code is as follows:
#绘制2维饼图x =read.delim ("C:/users/a/desktop/sample.txt", Header=false) #读入文本数据names (x) =c ("word", "count") #加表头x = Transform (x, Pct=round (X$count/sum (x$count) *100)) #数据框增加百分比列y =x[order (x[,2],decreasing=t),] #排序z =head (y,n=10) # Extract the first 10 lines percent <-paste (z$pct, "%", sep= "") #add% to Labelslbls <-paste (z$word,percent,sep= "\ n") #换行pie (z$pct, Labels=lbls,col=rainbow (Length (LBLS)), main= "Pie Chart of Word")
3D Pie Chart
650) this.width=650; "title=" QQ picture 20150430120050.png "alt=" wkiol1vbq1pqeb-yaaf8h78wxhu107.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/2d/wkiol1vbq1pqeb-yaaf8h78wxhu107.jpg "/>
Use the previous data to draw the R language The code for the 3D pie chart is as follows:
#3D饼图library ("Plotrix") Lp=pie3d (z$pct,radius=0.8,height=0.1,labels=lbls,explode=0.1,main= "3D pie DEMO") #调整标签位置 ( Effect not very good) lp[1] <-0.05 lp[3] <-3.2 pie3d (z$pct,radius=0.8,height=0.1,labels=lbls,labelpos=lp,explode=0.1,main= " 3D Pie DEMO ")
This article is from "Skywalker, in the Cloud" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1640879
R to draw a 3D pie chart