How to Create Plot of Weights at Spatial Locations (Connectivity Map)
조회 수: 5 (최근 30일)
이전 댓글 표시
I am wondering what tools in Matlab are available to create a plot of "connectivities" between different spatial locations. Basically, I have locations of data (I and P) as well as weights (f_IP) indicating the strength of the connection between each I and P, pointing from I to P. The plot I desire to create looks like the below:
Again, there are P weights pointing from each I toward each P. Larger weights are of larger size on the plot. Looking around, I have found Matlab functions that do similar things, but nothing quite like what I am looking for. Any guidance/recommendations would be appreciated.
댓글 수: 0
채택된 답변
Kelly Kearney
2021년 7월 1일
There aren't any pre-packaged functions to do this, but it should be pretty straightforward to create a function the calculates the vertices of each triangle shape given the coordinates of a P/I pair and the weight connecting them. You can then plot it as a multi-faceted patch. Example to come if I get some free time tomorrow...
댓글 수: 2
Kelly Kearney
2021년 7월 2일
An example... adjust as needed:
% Coordinates of I and P points
Ixy = [...
0 20
20 20
10 10
0 0
20 0];
Pxy = [...
10 20
0 10
20 10
10 0];
% Weights connecting I (rows) to P (columns)
w = [...
2 2 1 1
2 1 2 1
2 2 2 2
1 2 1 2
1 1 2 2]*2;
% Calculate angles between each I/P pair
[xi, xp] = ndgrid(Ixy(:,1), Pxy(:,1));
[yi, yp] = ndgrid(Ixy(:,2), Pxy(:,2));
dx = xp - xi;
dy = yp - yi;
ang = atan2(dy,dx);
% Calculate coordinates of triangles
dang = pi/30;
xpatch = [xi(:) xi(:)+w(:).*cos(ang(:)+dang) xi(:)+w(:).*cos(ang(:)-dang)]';
ypatch = [yi(:) yi(:)+w(:).*sin(ang(:)+dang) yi(:)+w(:).*sin(ang(:)-dang)]';
% Plot
patch(xpatch, ypatch, 'g');
axis equal;
text(Ixy(:,1), Ixy(:,2), compose('I%d', 1:size(Ixy,1)), 'horiz', 'center');
text(Pxy(:,1), Pxy(:,2), compose('P%d', 1:size(Pxy,1)), 'horiz', 'center');
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!