chordChart (chord diagram | 弦图)

Plot beautiful chord chart/chord diagram (好看的弦图/和弦图绘制)

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

You are now following this Submission

Plot beautiful chord chart (好看的弦图绘制), see demos for detail (详细使用请看demo).
Basic usage
dataMat=[2 0 1 2 5 1 2;
3 5 1 4 2 0 1;
4 0 5 5 2 4 3];
colName={'B1','G2','G3','G4','G5','G6','G7'};
rowName={'S1','S2','S3'};
% Create chord diagram object and draw (创建弦图对象并绘图)
CC=chordChart(dataMat,'RowName',rowName,'ColName',colName);
CC=CC.draw();
% Set Font for labels and show ticks (调整字体并显示刻度)
CC.setFont('FontSize',17,'FontName','Cambria')
CC.tickState('on')
CC.tickLabelState('on')
Set color source-side sub-square and target-side sub-square
+ Use obj.setSubSquareS | set Subordinate Square (Source)
+ or obj.setSubSquareT | set Subordinate Square (Target)
rng(3)
dataMat = randi([1, 15], [7, 22]); dataMat(dataMat < 11) = 0;
dataMat(1, sum(dataMat,1) == 0) = 15;
colName = {'A2M', 'FGA', 'FGB', 'FGG', 'F11', 'KLKB1', 'SERPINE1', 'VWF',...
'THBD', 'TFPI', 'PLAT', 'SERPINA5', 'SERPIND1', 'F2', 'PLG', 'F12',...
'SERPINC1', 'SERPINA1', 'PROS1', 'SERPINF2', 'F13A1', 'PROC'};
rowName = {'Lung', 'Spleen', 'Liver', 'Heart',...
'Renal cortex', 'Renal medulla', 'Thyroid'};
figure('Units','normalized', 'Position',[.02, .05, .6, .85])
CC = chordChart(dataMat, 'RowName',rowName, 'ColName',colName, 'Sep',1/80, 'LRadius',1.21, 'SSqRatio',1);
CC = CC.draw();
CC.labelRotate('on')
% Modify the color of the blocks below (修改下方方块颜色)
CListS = [128,108,171; 222,208,161; 180,196,229; 209,150,146; 175,201,166;
134,156,118; 175,175,173]./255;
CC.setSquareColorS(CListS)
% Modify chord color (修改弦颜色)
CC.setChordColorBySquareS()
Regulated = (rand([7, 22]) < .8) + 1; % Upregulated:1 | Downregulated:2
% Set individual end blocks for each chord (单独设置每一个弦末端方块)
% Use obj.setSubSquareS | set Subordinate Square (Source)
% or obj.setSubSquareT | set Subordinate Square (Target)
CC.setSubSquareT(Regulated == 1, 'FaceColor',[173, 70, 65]./255)
CC.setSubSquareT(Regulated == 2, 'FaceColor',[ 79,135,136]./255)
% Draw legend (绘制图例)
H1 = fill([0,1,0] + 100, [1,0,1] + 100, [173, 70, 65]./255, 'EdgeColor','none');
H2 = fill([0,1,0] + 100, [1,0,1] + 100, [ 79,135,136]./255, 'EdgeColor','none');
lgdHdl = legend([H1, H2], {'Upregulated','Downregulated'}, 'AutoUpdate','off', ...
'Location','best', 'Box','off', 'FontSize',13);
lgdHdl.ItemTokenSize = [12,12];
Set ori-square ratio and sub-square ratio
dataMat = round(10.*rand([11,4]).*((11:-1:1).'+1))./10;
colName = {'A','B','C','D'};
rowName = {'Acidobacteriota', 'Actinobacteriota', 'Proteobacteria', ...
'Chloroflexi', 'Bacteroidota', 'Firmicutes', 'Gemmatimonadota', ...
'Verrucomicrobiota', 'Patescibacteria', 'Planctomyetota', 'Others'};
figure('Units','normalized', 'Position',[.02,.05,.8,.85])
CC = chordChart(dataMat, 'ColName',colName, 'Sep',1/80, 'SSqRatio',-30/100, 'OSqRatio',80/100);
CC.RowName = repmat({' '}, [1, length(rowName)]);
CC = CC.draw();
% Modify the color of the blocks above (修改上方方块颜色)
CListT = [.93,.60,.62; .55,.80,.99; .95,.82,.18; 1.0,.81,.91];
CC.setSquareColorT(CListT)
% Modify the color of the blocks below (修改下方方块颜色)
CListS = [.75,.73,.86; .56,.83,.78; .00,.60,.20; 1.0,.49,.02; .78,.77,.95; .59,.24,.36;
.98,.51,.45; .96,.55,.75; .47,.71,.84; .65,.35,.16; .40,.00,.64];
CC.setSquareColorS(CListS)
% Modify chord color (修改弦颜色)
CC.setChordColorBySquareS()
% CC.setChordColorBySquareT()
CC.tickState('on')
CC.setFont('FontName','Cambria', 'FontSize',17)
% Draw legend (绘制图例)
lgdHdl = legend(CC.squareFHdl, rowName, 'Location','eastoutside', ...
'FontSize',16, 'FontName','Cambria', 'Box','off');
lgdHdl.ItemTokenSize = [18,8];
Rotation
The 'Rotation' attribute is used to rotate the entire shape
dataMat = rand([14,5]) > .3;
colName = {'phosphorylation', 'vasculature development', 'blood vessel development', ...
'cell adhesion', 'plasma membrane'};
rowName = {'THY1', 'FGF2', 'MAP2K1', 'CDH2', 'HBEGF', 'CXCR4', 'ECSCR',...
'ACVRL1', 'RECK', 'PNPLA6', 'CDH5', 'AMOT', 'EFNB2', 'CAV1'};
figure('Units','normalized', 'Position',[.02,.05,.9,.85])
CC = chordChart(dataMat, 'ColName',colName, 'RowName',rowName, 'Sep',1/80, 'LRadius',1.2, 'Rotation',3*pi/2).draw();
% Modify the color of the blocks above (修改上方方块颜色)
CListT = [0.47 0.58 0.75; 0.48 0.54 0.58; 0.65 0.72 0.65; 0.94 0.92 0.90; 0.98 0.76 0.68];
CC.setSquareColorT(CListT);
CC.setSquareT('EdgeColor',[0,0,0])
% Modify chord color (修改弦颜色)
CC.setChordColorBySquareT()
CC.setChord('FaceAlpha',.9, 'EdgeColor',[0,0,0])
% Modify the color of the blocks below (修改下方方块颜色)
logFC = sort(rand(1, 14))*6 - 3;
CC.setSquareCDataS(logFC)
CC.setSquareS('EdgeColor',[0,0,0])
% A diverging red-white-blue colormap (一个红白蓝配色 colormap)
CMap = interp1([0,.5,1].', [0,0,1;1,1,1;1,0,0], linspace(0,1,50).');
colormap(CMap); clim([-3,3]); colorbar('Position', [.74,.25,.02,.2]);
% Draw legend
text([1.25, 1.25], [-.15, 1], {'LogFC', 'Terms'}, 'FontSize',16)
lgdHdl = legend(CC.squareTHdl, colName, 'Position',[.735,.53,.167,.27], 'FontSize',14, 'Box','off');
lgdHdl.ItemTokenSize = [18,8];
Square, tick, label radius
More convenient radius control:
Add highlight arrow
dataMat = [2 0 1 2 5 1 2;
3 5 1 4 2 0 1;
4 0 5 5 2 4 3];
CC = chordChart(dataMat);
CC = CC.draw();
CC.addHighlightArrow(3, 4)
CC.addHighlightArrow(2, 2)

Cite As

Zhaoxu Liu / slandarer (2026). chordChart (chord diagram | 弦图) (https://in.mathworks.com/matlabcentral/fileexchange/116550-chordchart-chord-diagram), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
7.2.5

Update README.md

7.2.4

Update description.

7.2.3

Update README.md

7.2.2

Update README.md

7.2.1

debug

7.2.0

For methods: Added support for logical matrix inputs.

7.1.0

Added setChordCData setSquareCDataS setSquareCDataT method
Refine the inline comments for methods

7.0.2

debug

7.0.1

debug

7.0.0

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

6.0.3

Improved description.

6.0.2

Improved description.

6.0.1

Improved description.

6.0.0

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

5.0.0

More convenient radius control, new property name shorthands, and more user-friendly coloring functions

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)

4.0.1

More English Support

4.0.0

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

3.1.3

The bug, which prevented certain strings from being used as variable names due to the use of the `table` function during the struct construction process in the previous version, has been fixed.

3.1.2

Fixed the bug related to incorrect column labels.

3.1.1

+ 新增辅助属性`OSqRatio`用来调整原本弧形块占比 (demo9)
The 'OSqRatio' attribute can be used to adjust
the ratio of original arc-shaped blocks(demo9)
+ 新增辅助属性`Rotation`用来整体旋转图形
The 'Rotation' attribute is used to rotate the entire shape(demo12)

3.1.0

support R2018b

3.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

2.2.0

+ 可使用`SSqRatio`属性调整弦末端弧形块占比
The 'SSqRatio' attribute can be used to adjust
the ratio of arc-shaped blocks at the end of the chord

2.1.1

修复了老版本部分标签错误旋转的bug
Fixed a bug with incorrect rotation of some labels in older versions

2.1.0

+ 单独设置每一个弦末端方块(Set individual end blocks for each chord)
Use obj.setEachSquareT_Prop
or obj.setEachSquareF_Prop
F means from (blocks below)
T means to (blocks above)

1.7.4

add Copyright

1.7.3

Adjust numeric string format

1.7.2

fix labelRotate

1.7.1

add function setTickFont

1.7.0

Added attribute 'LRadius' with adjustable Label radius
Added attribute 'LRotate' and function `labelRatato` with adjustable Label rotate
Colors can be adjusted directly using the function `colormap`
Use function `tickLabelState` to disp tick labels

1.6.0

修复了老版本 sum(....,[1,2])的bug
Fixed the bug of the old version(sum(....,[1,2]))
增添了可调节方块间距的属性'Sep'
Added attribute 'Sep' with adjustable square spacing
增添demo3 旋转标签角度示例
demo3 is added to show how to rotate the label

对1.5.0的间距控制做了调整

1.5.0

修复了老版本 sum(....,[1,2])的bug
Fixed the bug of the old version(sum(....,[1,2]))
增添了可调节方块间距的属性'Sep'
Added attribute 'Sep' with adjustable square spacing
增添demo3 旋转标签角度示例
demo3 is added to show how to rotate the label

1.0.0