Coordinates of nodes in plot graph
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Maximilian Krahn
le 1 Fév 2021
Réponse apportée : Steven Lord
le 1 Fév 2021
Hi,
after displaying a graph with the "Force Directed" algorithm by calling
plot(graph(G), 'force')
I would like to get the coordinates of the nodes of the displayed graph. Is there a way to extract them or to only call the "Force Directed" algorithm to get those?
Best Regards
0 commentaires
Réponse acceptée
Steven Lord
le 1 Fév 2021
B = graph(bucky);
h = plot(B);
X = h.XData;
Y = h.YData;
fprintf("Node 1 is located at (%f, %f)\n", X(1), Y(1))
% Turn on the axes ticks so you can check the coordinates
ax = ancestor(h, 'axes');
ax.XTickMode = 'auto';
ax.YTickMode = 'auto';
xticks(-5:5)
% Draw lines -- X marks the spot
xline(X(1), 'r')
yline(Y(1), 'r')
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
