Coordinates of nodes in plot graph

7 ビュー (過去 30 日間)
Maximilian Krahn
Maximilian Krahn 2021 年 2 月 1 日
回答済み: Steven Lord 2021 年 2 月 1 日
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

採用された回答

Steven Lord
Steven Lord 2021 年 2 月 1 日
Copying my answer from this Answers post:
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))
Node 1 is located at (0.103347, -1.803899)
% 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 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by