R-pie ()

Source: Internet
Author: User
Tags explode
General pie chart:
> table (iris[,4])

0.1 0.2 0.3 0.4 0.5 0.6   1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9   2 2.1 2.2 2.3 2.4 2.5 
  5   7   7   1   1   7   3   5   8 4 2/5   6   6   3   8   3   3 
> Pie (Table (iris[,4]))

parameter Comment: main: You can add a master title.



3D pie chart:

> Library (Plotrix)
> Elem = C (' A ', ' B ', ' C ', ' d ', ' E ')
> num = C (12,32,14,42,20)
> numsum = SUM ( num)
> percent = Round (num/numsum*100,2)
> percent
[1] 10.00 26.67 11.67 35.00 16.67
> Percent = paste (percent, '% ', sep= ')
> Percent
[1] "Ten%"    "26.67%" "11.67    %" "16.67" "
  
   > pielabels = paste (elem,percent,sep= ' \ n ')
> Pie3d (num,main= ' My  3d-pie ', labels=pielabels,explode= 0.1,radius=0.8,height=0.1)
  

Note: the first thing to download is to install the Plotrix package. The round () function in percent = Round (num/numsum*100,2) is rounded and takes 2 decimal places, at which point the percent is the shaping vector. Percent = paste (percent, '% ', sep= ') in paste () is a string connection, and percent becomes a character vector after completion. Pie3d () Parameter:
Main: Pie chart main title. Labels: Tags for each "block". Explode: The interval between each "block", the default value is 0. Radius: The entire "pie" size, the default value is 1,0~1 to zoom out. Height: The width of the pie block, the default value is 0.1.


Reprint Please indicate the source, thank you. (Original link: http://blog.csdn.net/bone_ace/article/details/45076557)

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.