MATLAB: Coordinates of nodes in plot graph

graphplot

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

Best Answer

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')