biChordChart (bidirectional chord diagram | 有向弦图)

Plot bidirectional/directed/self-loop/self-links chord diagram (绘制 有向/双向 弦图/和弦图)

https://github.com/slandarer/MATLAB-chord-diagram

Vous suivez désormais cette soumission

Plot bidirectional/directed/self-loop/self-links chord diagram (绘制 有向/双向 弦图/和弦图)
Cover
Basic usage
dataMat=randi([0,8],[5,5]);
% 创建弦图对象(Create bichord diagram object and draw)
BCC=biChordChart(dataMat,'Arrow','on');
BCC=BCC.draw();
% 添加刻度(Show ticks and tick labels)
BCC.tickState('on')
BCC.tickLabelState('on')
% 修改字体,字号及颜色(Set font properties)
BCC.setFont('FontName','Cambria','FontSize',17)
The automatic adjustment of scale density
rng(1)
dataMat=randi([0,5],[8,8]);
CList=[ 75,146,241; 252,180, 65; 224, 64, 10; 5,100,146; 191,191,191;
26, 59,105; 255,227,130; 18,156,221; 202,107, 75; 0, 92,219;
243,210,136; 80, 99,129; 241,185,168; 224,131, 10; 120,147,190]./255;
figure('Units','normalized','Position',[.02,.05,.6,.85])
% TickMode 'value'(default)/'linear'/auto
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList,...
'TickMode','auto', 'SSqRatio',-30/100, 'OSqRatio',80/100);
BCC=BCC.draw();
% 添加刻度
BCC.tickState('on')
BCC.tickLabelState('on')
Square, tick, label radius | square ratio
Add highlight arrow
rng(1)
dataMat=randi([1,8], [4,4]);
% 创建弦图对象(Create bichord diagram object)
BCC=biChordChart(dataMat,'Arrow','on','Sep',1/12);
% 开始绘图(Start drawing)
BCC=BCC.draw();
% 添加刻度(Show ticks and tick labels)
BCC.tickState('on')
BCC.tickLabelState('on')
% 修改字体,字号及颜色(Set font properties)
BCC.setFont('FontName','Cambria','FontSize',17)
BCC.addHighlightArrow(2, 3)
BCC.addHighlightArrow(2, 1)
BCC.addHighlightArrow(4, 4)
Highlight chords originating from a specific node
dataMat = rand([15, 15]);
dataMat(dataMat > .2) = 0;
CList = [ 67,115,181; 173,136, 76; 156, 66, 43; 25, 88,124; 136,142,151;
37, 63,100; 175,164,115; 32,121,169; 143, 92, 82; 22, 83,168;
167,154,118; 70, 87,114; 166,139,138; 156,106, 43; 94,116,151]./255;
figure('Units','normalized', 'Position',[.02,.05,.6,.85])
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList);
BCC = BCC.draw();
BCC.tickState('on')
BCC.setFont('FontName','Cambria', 'FontSize',17, 'Color',[0,0,0])
% Modify chord color (修改弦颜色)
BCC.setChord('FaceColor',[ 54, 69, 92]./255 ,'FaceAlpha',.07)
% Highlight chords originating from a specific node (高亮以某节点为源的弦)
[~, N] = max(sum(dataMat > 0, 2));
BCC.setChord(N, [], 'FaceColor',CList(N,:), 'FaceAlpha',.6)
A colorful demo
dataMat = rand([9, 9]); dataMat(dataMat > .7) = 0;
dataMat(eye(9) == 1) = (rand([1,9]) + .2).*3;
CList = [.85,.23,.24; .96,.39,.18; .98,.63,.22; .99,.80,.26; .70,.76,.21;
.24,.74,.71; .27,.65,.84; .09,.37,.80; .64,.40,.84];
figure('Units','normalized', 'Position',[.02,.05,.6,.85])
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList, 'TickMode','linear');
BCC.LinearMinorTick = 'on';
BCC = BCC.draw();
BCC.tickState('on')
BCC.tickLabelState('on')
BCC.setFont('FontName','Cambria', 'FontSize',17)
BCC.setChord('FaceAlpha',.7)
Another colorful demo
rng(2)
dataMat = rand([12, 12]);
dataMat(dataMat < .85) = 0;
dataMat(7,:) = 1.*(rand(1, 12) + .1);
dataMat(11,:) = .6.*(rand(1, 12) + .1);
dataMat(12,:) = [2.*(rand(1 ,10) + .1), 0, 0];
CList = [repmat([49,49,49],[10,1]); 235,28,34; 19,146,241]./255;
figure('Units','normalized', 'Position',[.02,.05,.6,.85])
BCC = biChordChart(dataMat, 'Arrow','off', 'CData',CList);
BCC = BCC.draw();
BCC.tickState('on')
BCC.setFont('FontName','Cambria', 'FontSize',17)
BCC.setChord('FaceAlpha',.78, 'EdgeColor',[0,0,0])
BCC.setSquare('EdgeColor',[0,0,0], 'LineWidth',2)
Reproduction of a Nature figure example
% Reproduced from:
% Merchant, A.T., King, S.H., Nguyen, E. et al.
% Semantic design of functional de novo genes from a genomic language model.
% Nature 649, 749–758 (2026). https://doi.org/10.1038/s41586-025-09749-7
see demo16.m for detail:
Reproduction of another Nature figure example
% Data source :
% Lake, B.B., Menon, R., Winfree, S. et al.
% An atlas of healthy and injured cell states and niches in the human kidney.
% Nature 619, 585–594 (2023). https://doi.org/10.1038/s41586-023-05769-3
% https://www.nature.com/articles/s41586-023-05769-3
% 41586_2023_5769_MOESM9_ESM.xlsx | sheet : panel_d_chordplot
see demo11.m for detail:

Citation pour cette source

Zhaoxu Liu / slandarer (2026). biChordChart (bidirectional chord diagram | 有向弦图) (https://fr.mathworks.com/matlabcentral/fileexchange/121043-bichordchart-bidirectional-chord-diagram), MATLAB Central File Exchange. Extrait(e) le .

Informations générales

Compatibilité avec les versions de MATLAB

  • Compatible avec toutes les versions

Plateformes compatibles

  • Windows
  • macOS
  • Linux
Version Publié le Notes de version Action
7.1.2

debug

7.1.1

Change cover

7.1.0

For methods: Added support for logical matrix inputs

7.0.1

debug

7.0.0

+ Replace 'F' with 'S' (Source replaces From-side).

6.0.0

+ Optimized variable and graphics object name display
+ Significantly improved plotting speed for large-scale matrices

5.0.1

Debug.

5.0.0

More convenient radius control, new property name shorthands.

4.1.4

Improved the documentation comments.

4.1.3

Improved the documentation comments.

4.1.2

A bug causing certain components not to render in specific axes has been resolved. Additionally, several examples have been simplified.

4.1.1

change Project Website.

4.1.0

# version 4.1.0
+ 使用 addHighlightArrow 添加提示箭头
Use function addHighlightArrow to add arrow(demo13)
+ 节点可分组
Nodes are groupable(demo14)

4.0.1

More English support

4.0.0

+ 左键添加数据提示框,右键隐藏高亮
Left-click to add data tooltip, right-click to hide highlight

3.0.0

`SSqRatio` `OSqRatio` `Rotation`

2.0.1

support R2018b

2.0.0

+ 新增两种标志刻度的方法
Added 2 methods to adjust ticks
try : CC = chordChart(..., 'TickMode','auto', ...)

+ 'value' : default

+ 'auto' : 当有刻度离得很近的时候,绘制斜线将其距离拉远
When there are scales that are very close, draw a diagonal line

1.1.4

Fixed a bug with incorrect rotation of some labels in older versions

1.1.3

Fixed nan issue and text overlap issue when all elements of matrix rows or columns are 0

1.1.2

add Copyright

1.1.1

Adjust numeric string format

1.1.0

Added attribute 'LRadius' with adjustable Label radius
Added attribute 'LRotate' and function `labelRatato` with adjustable Label rotate(demo3)
Use function `tickLabelState` to display tick labels(demo4)

1.0.0