How to Create Plot of Weights at Spatial Locations (Connectivity Map)
4 views (last 30 days)
Show older comments
Corey Hoydic
on 30 Jun 2021
Commented: Kelly Kearney
on 2 Jul 2021
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 Comments
Accepted Answer
Kelly Kearney
on 1 Jul 2021
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 Comments
Kelly Kearney
on 2 Jul 2021
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');
More Answers (0)
See Also
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!