我想在节点图上表示具有连接强度的互连节点的集合。
每个节点都有一个介于0和1之间的值矩阵,用于连接所有其他节点的强度,I.E:
[1.0000 0.1000 0.1200 0.0010]
[0.1000 1.0000 0.0820 0.0001]
...
其中列表示节点强度和行节点。
我希望在图表上放置节点是合理的 - 即一组强连接节点应该在图表上相对分组。
如何在Matlab中最简单地完成?我已经看过gplot
,但我不确定它是否完全符合我的目标。
这是一个简单矩阵的例子:
strengths=[1,0,0,0,0,0,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,0,0,0,0,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,1,0,0,0,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,1,0,0,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,1,0,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,1,0,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,1,0,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,1,0,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,1,0,0.909090909091,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,1,1.0,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0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1.0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.909090909091,1,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1.0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.909090909091,1,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1.0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.909090909091,1,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
答案 0 :(得分:0)
我正在向你展示我的尝试,但不幸的是我还没有想到如何根据他们与其他人的距离来定义点的XY位置....
然而,我在这里留下一段代码,用于绘制您想要的类似图表,而不是节点的位置,以及强度"我改变了它们之间的线条颜色。
对于更丰富多彩的绘图,您可以将灰度颜色更改为颜色图(即' jet')。
我希望其他人能更好地解决它!
% your stegths are of 1,0.9 or 0 value. I suppose that in general you have
% 0-1 range, so just for this example, i am going to comvert the 0.9 into
% 0.5, so you can see the changes in colour.
strengths(strengths>0&strengths<1)=0.5;
w=sum(strengths,2);
w=w/max(w);
% I dont have any idea how to do this....
% so I will create random points. Sorry :(
XY=rand(size(strengths,1),2);
isconect=strengths>0;
h=figure
hold on
for ii=1:size(strengths,1)
plot(XY(ii,1),XY(ii,2),'k.','markersize',50*w(ii))
for jj=1:sum(isconect(ii,:))-1
idx=find(isconect(ii,:));
idx=idx(jj+1);
wc=strengths(ii,idx);
plot([XY(ii,1) XY(idx,1)],[XY(ii,2) XY(idx,2)],'color',ones(3,1)*(1-wc),'linewidth',2*wc)
end
end
set(gcf, 'Color', [1,1,1]);
axis off;
编辑:为了避免在圆圈上绘制线条,只需更改绘图的顺序(即绘制线条后的点)。我很糟糕,我只是匆忙做到了。