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

4 vues (au cours des 30 derniers jours)
Corey Hoydic
Corey Hoydic le 30 Juin 2021
Commenté : Kelly Kearney le 2 Juil 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.

Réponse acceptée

Kelly Kearney
Kelly Kearney le 1 Juil 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 commentaires
Corey Hoydic
Corey Hoydic le 2 Juil 2021
Hello Kelly - thank you for this. I will attempt implementation on my end in the meantime.
Kelly Kearney
Kelly Kearney le 2 Juil 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');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by