-
Notifications
You must be signed in to change notification settings - Fork 1
/
ComplexDiagram.m
60 lines (43 loc) · 1.33 KB
/
ComplexDiagram.m
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
function [cax, indices_sorted] = ComplexDiagram(varargin)
% Ex. ComplexDiagram(complexes, w_mc_complexes, Res)
[cax,args] = axescheck(varargin{:});
complexes = args{1};
phis = args{2};
Res = args{3};
if isempty(cax) || ishghandle(cax,'axes')
cax = newplot(cax);
parent = cax;
else
parent = cax;
cax = ancestor(cax,'axes');
end
[phis_sorted, index_phis_sorted] = sort(phis, 'ascend');
complexes_sorted = complexes(index_phis_sorted);
%%
[~, indices_sorted] = sortIndicesAccordingToHierarchicalStructure(Res);
[~, order_inverse] = sort(indices_sorted);
nCs = length(phis);
nElems = size(Res.Z, 2);
%cla reset
complexBoxes = zeros(nElems);
for iCs = 1:nCs
indices = complexes_sorted{iCs};
indices_inverse = order_inverse(indices);
minIndex = min(indices_inverse);
maxIndex = max(indices_inverse);
complexBoxes(minIndex:maxIndex, minIndex:maxIndex) = phis_sorted(iCs);
end
imagesc(cax, complexBoxes)
hold on
for iCs = 1:nCs
indices = complexes_sorted{iCs};
indices_inverse = order_inverse(indices);
minIndex = min(indices_inverse);
maxIndex = max(indices_inverse);
minCoor = minIndex-0.5;
maxCoor = maxIndex+0.5;
xs_c = [minCoor maxCoor maxCoor minCoor minCoor];
ys_c = [minCoor minCoor maxCoor maxCoor minCoor];
line(cax, xs_c, ys_c, 'color', 'w')%colors(iCs,:))
end
end