-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsankeyDemo7.m
More file actions
75 lines (63 loc) · 2.01 KB
/
Copy pathsankeyDemo7.m
File metadata and controls
75 lines (63 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%% sankey demo7 : A website example
figure('Name','sankey demo7','Units','normalized','Position',[.05,.2,.5,.56])
clc;clear;
links{7,3}='';
for i=1:7
links{i,1}=['浏览',num2str(i)];
links{i,2}=['浏览',num2str(i+1)];
links{i,3}=10000-1400*i;
end
for i=1:7
links{i+7,1}=['浏览',num2str(i)];
links{i+7,2}=['下载',num2str(i)];
links{i+7,3}=900;
end
for i=1:7
links{i+14,1}=['浏览',num2str(i)];
links{i+14,2}=['流失',num2str(i)];
links{i+14,3}=500;
if i>=3
links{i+14,3}=1100;
end
end
for i=1:6
links{i+21,1}=['下载',num2str(i)];
links{i+21,2}=['浏览',num2str(i+2)];
links{i+21,3}=600;
end
for i=1:6
links{i+27,1}=['下载',num2str(i)];
links{i+27,2}=['流失',num2str(i+1)];
links{i+27,3}=300;
end
% 创建桑基图对象(Create a Sankey diagram object)
SK=SSankey(links(:,1),links(:,2),links(:,3));
SK.NodeList={'浏览1','浏览2','浏览3','浏览4','浏览5','浏览6','浏览7','浏览8',...
'下载1','下载2','下载3','下载4','下载5','下载6','下载7',...
'流失1','流失2','流失3','流失4','流失5','流失6','流失7'};
SK.ColorList=[197,141,91;69,168,134;114,191,220;193,135,146;242,132,98;249,190,89;207,202,100;171,203,110;
repmat([114,158,158],[7,1]);repmat([100,136,177],[7,1])]./255;
% Set alignment (修改对齐方式)
% 'up'/'down'/'center'(default)
SK.Align='down';
% Set link color rendering method (修改链接颜色渲染方式)
% 'left'/'right'/'interp'(default)/'map'/'simple'
SK.RenderingMethod='left';
% Set Text Location (修改文本位置)
% 'left'(default)/'right'/'top'/'center'/'bottom'
SK.LabelLocation='right';
% Set the scale of blocks (设置方块占比)
% BlockScale>0 & BlockScale<1
SK.BlockScale=.16;
% Start drawing (开始绘图)
SK.draw()
% Loop Set Label Properties (循环设置标签属性)
for i=1:22
SK.setLabel(i,'FontName','宋体','FontSize',12)
end
for i=10:15
SK.moveBlockY(i,(9-i).*1000);
end
for i=17:22
SK.moveBlockY(i,(16-i).*1000);
end