R Draws a 3D pie chart _R/HBASE/SOLR

Source: Internet
Author: User
Tags explode solr

Two-dimensional pie chart

The code is as follows:

X=read.delim ("C:/users/a/desktop/sample.txt", Header=false) #读入文本数据
names (x) =c ("word", "count") # Add Header
x=transform (x, Pct=round (X$count/sum (x$count) *100)) #数据框增加百分比列
Y=x[order (x[,2],decreasing=t),] #排序
Z=head (y,n=10) #抽取前10行
percent <-paste (z$pct, "%", sep= ") #add% to labels Lbls <-paste
(Z$word, Percent,sep= "\ n") #换行
Pie (z$pct,labels=lbls,col=rainbow length (lbls), main= "Pie Chart of Word")

3D Pie Chart

Following the previous data, the code to draw the R language to draw the 3D pie chart is as follows:

Library ("Plotrix") Lp=pie3d (z$pct,radius=0.8,height=0.1,labels=lbls,explode=0.1,main= "3D pie DEMO")

#调整标签位置 (not 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 from the "Drip accumulation" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1640879

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.