https://r-charts.com/flow/chord-diagram/
image.png
require(circlize) '
require(ggplot2)
#--------------------------------------------------#
df_used <- data.frame(from=rep(rownames(m), ncol(m)), to=rep(colnames(m), each = nrow(m)), value=as.vector(m))
chordDiagram(df_used)
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
colors <- c(Col1 = "lightgrey", Col2 = "grey",
Col3 = "darkgrey", Row1 = "#FF410D",
Row2 = "#6EE2FF", Row3 = "#F7C530",
Row4 = "#95CC5E", Row5 = "#D0DFE6")
chordDiagram(df_used, grid.col = colors) #grid.col=, 指定圆圈外围的颜色
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
chordDiagram(df_used, transparency=0.5) #transparency=, 指定中间线条的透明度
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
chordDiagram(df_used, col = hcl.colors(15)) #col =, 指定中间线条的颜色
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
col_range <- colorRamp2(range(df_used[,3]), c("#E5FFFF", "#003FFF")) #使用梯度颜色
chordDiagram(df_used, col = col_range)
#--------------------------------------------------#
#修饰中间连线
circos.clear() #Restart circular layout parameters
cols <- hcl.colors(15, "Temps")
chordDiagram(df_used, col = cols, transparency = 0.1, link.lwd = 1, link.lty = 1, link.border = 1)
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
#不显示外圈注释并调节外圈厚度
chordDiagram(df_used, annotationTrack = "grid", annotationTrackHeight=c(0.05,0.05))
#--------------------------------------------------#
circos.clear() #Restart circular layout parameters
#对外圈名进行标注
chordDiagram(df_used, column.col = c("red", "green", "blue"), annotationTrack = c("name", "grid"))
网友评论