pie(x, labels = names(x), edges = 200, radius = 0.8, clockwise = FALSE, init.angle = if(clockwise) 90 else 0, density = NULL, angle = 45, col = NULL, border = NULL, lty = NULL, main = NULL, ...)
参数说明:x:非负的数值向量,表示每个扇形的面积;
labels:各扇形面积标签的字符型向量;
radius :表示饼图的圆的半径,取值-1到1之间;
clockwise :逻辑值,用来指示饼图各个切片是否按顺时针做出分割;
init.angle:扇形面积起始角度,默认是0。如clockwise为真,init.angle默认取值90度;
code及示例:par(mfrow=c(2,3))
pie(c(1,2,3,4),)
pie(c(1,2,3,4),labels = c("e","w","n","s"))
pie(c(1,2,3,4),labels = c("e","w","n","s"),clockwise = TRUE)
pie(c(1,2,3,4),labels = c("e","w","n","s"),clockwise = TRUE,col = c("red","gray","green","black"))
pie(c(1,2,3,4),labels = c("e","w","n","s"),density = 10,clockwise = TRUE,col = c("red","gray","green","black"))
pie(c(1,2,3,4),labels = c("e","w","n","s"),density=10,angle=60,clockwise = TRUE,col =
补充:
1、饼图数据标签以百分数来表示
2、3D饼图的绘制方式
利用包plotrix中函数pie3D
pie3D(x,edges=NA,radius=1,height=0.1,theta=pi/6,start=0,border=par("fg"), col=NULL,labels=NULL,labelpos=NULL,labelcol=par("fg"),labelcex=1.5, sector.order=NULL,explode=0,shade=0.8,mar=c(4,4,4,4),pty="s",...)参数说明:radius:半径,默认取值1;height:饼块的高度,默认值为0.1;
start:绘制每一个冰块的起始角度,默认值为0;
labelpos:标签的可选位置;
sector.order:制定每个冰块的绘制顺序;
explode:冰块间距,默认取值0;
shade:取值0到1之间时,则降低扇区颜色的亮度以获得更好的3D效果。默认取值0.8;
pty:是否控制绘图区域,默认取值s(表示不能调整绘图区域),如取值m,可调整业边距;
code及示例
par(mfrow=c(2,3))
l<-c(1,2,3,4)
names<-c("a","b","c","d")
pct<-l/sum(l)*100
l1<-paste(pct,sep="","%")
l2<-paste(names,sep = " ",l1)
pie(l,labels = l2)
library(plotrix)
pie3D(l,labels=l2)
pie3D(l,labels = l2,explode = 0.1)
pie3D(l,labels = l2,explode = 0.1,col = terrain.colors(length(l)))
pie3D(l,labels = l2,explode = 0.1,col = terrain.colors(length(l)),shade = 0.1)
pie3D(l,labels = l2,explode = 0.1,col = terrain.colors(length(l)),shade = 0.1,sector.order = 4:1)
3、扇形图的绘制函数
fan.plot(x,edges=200,radius=1,col=NULL,align.at=NULL,max.span=NULL, labels=NULL,labelpos=NULL,label.radius=1.2,align="left",shrink=0.02, main="",ticks=NULL,include.sumx=FALSE,...)
示例及图形fan.plot(l,labels = names,main = "simple chart")
暂无数据