biChordChart (bidirectional chord diagram | 有向弦图)

bidirectional/directed/self-loop/self-links chord diagram 有向弦图

Sie verfolgen jetzt diese Einreichung

bidirectional chord diagram 有向弦图
Basic usage
dataMat=randi([0,8],[6,6]);
% 添加标签名称
NameList={'CHORD','CHART','MADE','BY','SLANDARER','MATLAB'};
BCC=biChordChart(dataMat,'Label',NameList,'Arrow','on');
BCC=BCC.draw();
% 添加刻度
BCC.tickState('on')
% 修改字体,字号及颜色
BCC.setFont('FontName','Cambria','FontSize',17,'Color',[.2,.2,.2])
BCC.setLabelRadius(1.3);
BCC.tickLabelState('on')
The 'SSqRatio' attribute can be used to adjust
the ratio of arc-shaped blocks at the end of the chord
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')
biChordChart with 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)
More demos
dataMat = rand([15,15]);
dataMat(dataMat > .2) = 0;
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;
CListC = [54,69,92]./255;
CList = CList.*.6 + CListC.*.4;
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)
for i = 1:size(dataMat, 1)
for j = 1:size(dataMat, 2)
if dataMat(i,j) > 0
BCC.setChordMN(i,j, 'FaceColor',CListC ,'FaceAlpha',.07)
end
end
end
[~, N] = max(sum(dataMat > 0, 2));
for j = 1:size(dataMat, 2)
BCC.setChordMN(N,j, 'FaceColor',CList(N,:) ,'FaceAlpha',.6)
end
CList = [0.81,0.72,0.83
0.69,0.82,0.89
0.17,0.44,0.64
0.70,0.85,0.55
0.03,0.57,0.13
0.97,0.67,0.64
0.84,0.09,0.12
1.00,0.80,0.46
0.98,0.52,0.01
];
figure('Units','normalized', 'Position',[.02,.05,.53,.85], 'Color',[1,1,1])
% =========================================================================
ax1 = axes('Parent',gcf, 'Position',[0,1/2,1/2,1/2]);
dataMat = rand([9,9]);
dataMat(dataMat > .4) = 0;
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList);
BCC = BCC.draw();
BCC.tickState('on')
BCC.setFont('Visible','off')
% 修改弦颜色(Modify chord color)
for i = 1:size(dataMat, 1)
for j = 1:size(dataMat, 2)
if dataMat(i,j) > 0
BCC.setChordMN(i,j, 'FaceAlpha',.6)
end
end
end
text(-1.2,1.2, 'a', 'FontName','Times New Roman', 'FontSize',35)
% =========================================================================
ax2 = axes('Parent',gcf, 'Position',[1/2,1/2,1/2,1/2]);
dataMat = rand([9,9]);
dataMat(dataMat > .4) = 0;
dataMat = dataMat.*(1:9);
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList);
BCC = BCC.draw();
BCC.tickState('on')
BCC.setFont('Visible','off')
% 修改弦颜色(Modify chord color)
for i = 1:size(dataMat, 1)
for j = 1:size(dataMat, 2)
if dataMat(i,j) > 0
BCC.setChordMN(i,j, 'FaceAlpha',.6)
end
end
end
text(-1.2,1.2, 'b', 'FontName','Times New Roman', 'FontSize',35)
% =========================================================================
ax3 = axes('Parent',gcf, 'Position',[0,0,1/2,1/2]);
dataMat = rand([9,9]);
dataMat(dataMat > .4) = 0;
dataMat = dataMat.*(1:9).';
BCC = biChordChart(dataMat, 'Arrow','on', 'CData',CList);
BCC = BCC.draw();
BCC.tickState('on')
BCC.setFont('Visible','off')
% 修改弦颜色(Modify chord color)
for i = 1:size(dataMat, 1)
for j = 1:size(dataMat, 2)
if dataMat(i,j) > 0
BCC.setChordMN(i,j, 'FaceAlpha',.6)
end
end
end
text(-1.2,1.2, 'c', 'FontName','Times New Roman', 'FontSize',35)
% =========================================================================
ax4 = axes('Parent',gcf, 'Position',[1/2,0,1/2,1/2]);
ax4.XColor = 'none'; ax4.YColor = 'none';
ax4.XLim = [-1,1]; ax4.YLim = [-1,1];
hold on
NameList = {'Food supply', 'Biodiversity', 'Water quality regulation', ...
'Air quality regulation', 'Erosion control', 'Carbon storage', ...
'Water retention', 'Recreation', 'Soil quality regulation'};
patchHdl = [];
for i = 1:size(dataMat, 2)
patchHdl(i) = fill([10,11,12],[10,13,13], CList(i,:), 'EdgeColor',[0,0,0]);
end
lgdHdl = legend(patchHdl, NameList, 'Location','best', 'FontSize',14, 'FontName','Cambria', 'Box','off');
lgdHdl.Position = [.625,.11,.255,.27];
lgdHdl.ItemTokenSize = [18,8];
详情请见本人公众号/知乎/CSDN :slandarer

Zitieren als

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

Allgemeine Informationen

Kompatibilität der MATLAB-Version

  • Kompatibel mit allen Versionen

Plattform-Kompatibilität

  • Windows
  • macOS
  • Linux
Version Veröffentlicht Versionshinweise Action
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