R language draws a commercial pie chart with colorful color combinations based on the four-color theorem

library(RColorBrewer)
par(mfrow=c(2,2))
slices<-c(10,12,4,16,8)
lbls<-c("美国","中国","俄罗斯","德国","英国")
pie(slices,labels=lbls,main="简单饼图",
    col = brewer.pal(8,"Set3"))
pct<-round(slices/sum(slices)*100)
lbls2<-paste(lbls,"",pct,"%",sep="")
pie(slices,labels=lbls2,main="带有百分比的饼图",
    col = brewer.pal(8,"Set3"))
library(plotrix)
pie3D(slices,labels=lbls,explode=0.1,main="3D饼图",
      col= brewer.pal(8,"Set3"))
mytable<-table(state.region)
lbls3<-paste(names(mytable),"\n",mytable,sep="")
pie(mytable,labels=lbls3,main="从一张表绘制饼图\n(带有采样尺寸)",
    col= brewer.pal(8,"Set3"))

insert image description here

col= brewer.pal(8,"Set1")

insert image description here

library(RColorBrewer)
par(mfrow=c(2,2))
slices<-c(10,12,2,10,8,8,4,3)
lbls<-c("美国","中国","中国澳门","德国","英国","法国","中国台湾","中国香港")
pie(slices,labels=lbls,main="简单饼图",
    col = brewer.pal(8,"Set1"))
pct<-round(slices/sum(slices)*100)
lbls2<-paste(lbls,"",pct,"%",sep="")
pie(slices,labels=lbls2,main="带有百分比的饼图",
    col = brewer.pal(8,"Set1"))
library(plotrix)
pie3D(slices,labels=lbls,explode=0.1,main="3D饼图",
      col= brewer.pal(8,"Set1"))
mytable<-table(state.region)
lbls3<-paste(names(mytable),"\n",mytable,sep="")
pie(mytable,labels=lbls3,main="从一张表绘制饼图\n(带有采样尺寸)",
    col= brewer.pal(8,"Set1"))

insert image description here

col= brewer.pal(8,"Set2")

insert image description here

col= brewer.pal(8,"Pastel1")

insert image description here

col= brewer.pal(8,"Pastel2")

insert image description here

col = brewer.pal(8,"Paired")

insert image description here

col= brewer.pal(8,"Dark2")

insert image description here

col= brewer.pal(8,"Accent")

insert image description here

col= brewer.pal(8,"Spectral")

insert image description here

col= brewer.pal(8,"RdYlGn")

insert image description here

col= brewer.pal(8,"Reds")

insert image description here

col= brewer.pal(8,"Purples")

insert image description here

col= brewer.pal(8,"PiYG")

insert image description here

col= brewer.pal(8,"Blues")

insert image description here

col= brewer.pal(8,"Greens")

insert image description here

col= brewer.pal(8,"Greys")

insert image description here

col= brewer.pal(8,"Oranges")

insert image description here

col= brewer.pal(8,"OrRd")

insert image description here

col= brewer.pal(8,"BrBG")

insert image description here

col= brewer.pal(8,"PRGn")

insert image description here

col= brewer.pal(8,"PuOr")

insert image description here

 col= brewer.pal(8,"RdBu")

insert image description here
col= brewer.pal(8,“RdGy”)
insert image description here

col= brewer.pal(8,"RdYlBu")

insert image description here

col= brewer.pal(8,"RdYlGn")

insert image description here

col= brewer.pal(8,"BuGn")

insert image description here

col= brewer.pal(8,"BuPu")

insert image description here

col= brewer.pal(8,"GnBu")

insert image description here

col= brewer.pal(8,"YlOrBr")

insert image description here

col= brewer.pal(8,"YlGnBu")

insert image description here

col= brewer.pal(8,"YlGn")

insert image description here

col= brewer.pal(8,"RdPu")

insert image description here

col= brewer.pal(8,"PuRd")

insert image description here

col= brewer.pal(8,"PuBuGn")

insert image description here
References: https://blog.csdn.net/m0_38127487/article/details/132107471?spm=1001.2014.3001.5501
https://blog.csdn.net/weixin_58566962/article/details/126490526

Guess you like

Origin blog.csdn.net/m0_38127487/article/details/132122758