目录
基础饼图
标签个性化
边界修改
密度条纹
边框颜色
基础饼图
rm(list = ls())
# Create Data
Prop <- c(3,7,9,1,2)
# Make the default Pie Plot
P1 <- pie(Prop)
dev.off()
标签个性化
P2 <-pie(Prop , labels = c("Gr-A","Gr-B","Gr-C","Gr-D","Gr-E"))
dev.off()
边界修改
#边界修改:“edge”参数该参数决定了每个扇形边界的圆弧由多少条直线段近似组成。
#默认值:如果未指定,默认值通常是 200(可能会因版本而略有差异)。
P3 <-pie(Prop , labels = c("Gr-A","Gr-B","Gr-C","Gr-D","Gr-E") , edges=10)
dev.off()
密度条纹
#添加加带密度的条纹
P4 <-pie(Prop , labels = c("Gr-A","Gr-B","Gr-C","Gr-D","Gr-E") ,
density=10 , angle=c(20,90,30,10,0))
边框颜色
#带颜色和边框的颜色
library(RColorBrewer)
myPalette <- brewer.pal(5, "Set2")
#pdf("plot.pdf",width = 4,height = 4)##保存为pdf 一定添加大小
# You can change the border of each area with the classical parameters:
P5 <-pie(Prop , labels = c("Gr-A","Gr-B","Gr-C","Gr-D","Gr-E"), border="white", col=myPalette )
dev.off()
Pie plot with base R – the R Graph Gallery