# Calculating node coordinates for a graph without plot command

1 visualización (últimos 30 días)
Mannes Dreef el 15 de Jul. de 2022
Respondida: Christine Tobler el 2 de Ag. de 2022
Hello,
I'm using a custom plotting routine for a graph, to which I want to provide node coordinates that are calculated for a good representation. I have found a solution by plotting the graph in an invisible plot and extracting the coordinates:
s = [1 1 2 2 3];
t = [2 4 3 4 4];
G = digraph(s,t);
fig = figure('Visible', 'off');
h = gca;
graphPlot = plot(h,G,'layout', 'force','WeightEffect','direct');
allCoordinates(:,1) = graphPlot.XData
allCoordinates(:,2) = graphPlot.YData
close(fig);
However, this is quite inefficient... Is there a way to do this, without using the plotting routine?
Thanks!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Christine Tobler el 2 de Ag. de 2022
Unfortunately there isn't a way to get these coordinates without plotting. I have added your request for such a function to our internal tracker for new functionality requests.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by