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)