zoukankan      html  css  js  c++  java
  • R-pie()

    最简单的饼图:

    > 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  29   7   7   1   1   7   3   5  13   8  12   4   2  12   5   6   6   3   8   3   3 
    > pie(table(iris[,4]))

    这里写图片描述

    参数注释:

    • main:可以添加主标题。





    3D饼图:

    > 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] "10 %"    "26.67 %" "11.67 %" "35 %"    "16.67 %"
    > pieLabels = paste(elem,percent,sep='
    ')
    > pie3D(num,main='My  3D-Pie',labels=pieLabels,explode=0.1,radius=0.8,height=0.1)

    3D-Pie

    注释:

    • 首先要下载安装plotrix包!
    • percent = round(num/numSum*100,2)中round()作用是四舍五入,取2位小数,此时percent是整形向量。
    • percent = paste(percent,’%’,sep=’ ‘)中paste()作用是字符串连接,完后percent变成字符型向量。
    • pie3D()参数:
      • main:饼图主标题 。
      • labels:各个“块”的标签。
      • explode:各个“块”之间的间隔,默认值为0。
      • radius:整个“饼”的大小,默认值为1,0~1为缩小。
      • height:饼块的高度,默认值为0.1。
  • 相关阅读:
    【3-9】数据库基本应用
    Oracle所有分析函数<转>
    Oracle数据库row_number详解<转>
    MVC人员管理系统
    MVC Razor语法
    MVC基础
    邮箱验证
    jQuery入门基础(动画效果)
    js前台与后台数据交互
    ajax入门基础
  • 原文地址:https://www.cnblogs.com/Bone-ACE/p/4531300.html
Copyright © 2011-2022 走看看