R语言绘制弦状图
1.数据
2.程序代码
library(statnet)
library(circlize)
data<-read.csv("Bacteria otu.csv",header = T,row=1)
my.data<-as.matrix(data)
row.names(my.data)<-c("A1","B1","C1","D1")
colnames<-c("Proteobacteria","Actinobacteria","Bacteroidetes","Cyanobacteria","Firmicutes","Planctomycetes","Verrucomicrobia","Chloroflexi","Chlorobi","Thermomicrobia","Others")
grid.col=NULL
grid.col=c("blue","black","orenge","chocolate")
grid.col=c("lavender","khaki","mistyrose","siennal","skyblue","brownl","gold","maroon","scalmon","moccasin","wheat")
circos.par(gap.degree=c(rep(2,nrow(my.data)-1),10,rep(2,ncol(my.data)-1),10),start.degree=180)
chordDiagram(my.data,directional=TRUE,diffHeight=0.06,grid.col=grid.col,transparency=0.5)
legend("right",pch = 20,legend = colname(my.data),col = grid.col,bty = "n",cex=1,pt.cex=3,border="black")
pdf(file="circlize.pdf",width=8,height=5,pointsize=8)
chordDiagram(my.data,directional=TRUE,diffHeight=0.06,grid.col=grid.col,transparency=0.5)
legend("right",pch=20,legend=colnames(my.data),col=grid.col,bty="n",cex=1,pt.cex=3,border="black")
3.图形效果
页:
[1]