R Draw 3D Pie chart

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.