How to Create Plot of Weights at Spatial Locations (Connectivity Map)

3 ビュー (過去 30 日間)
Corey Hoydic
Corey Hoydic 2021 年 6 月 30 日
コメント済み: Kelly Kearney 2021 年 7 月 2 日
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.

採用された回答

Kelly Kearney
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 件のコメント
Corey Hoydic
Corey Hoydic 2021 年 7 月 2 日
Hello Kelly - thank you for this. I will attempt implementation on my end in the meantime.
Kelly Kearney
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 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by