Plotted a graph, want to specify label position relative to node
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I plotted a graph, but the node labels sometimes collide:
A=ceil(10*rand(30));
A=triu(A,1)+triu(A,1)';
NodeLabels = arrayfun( @(x)sprintf('x%010u',x) , 1:30 , ...
'Uniform',false);
GportDist = graph( A , NodeLabels );
ax=plot( GportDist, 'Layout','force' , ...
'WeightEffect','direct' , 'Interpreter','none');
I haven't found a way to specify the label position relative to the node, e.g., North, NorthEast, South, etc.
Is there a way to specify label positions relative to nodes?
I am using Matlab 2019a.
2 comentarios
dpb
el 8 de Jun. de 2021
You can try varying the 'HorizontalAlignment', 'VerticalAlignment' and perhaps the 'Rotation' properties...
Respuesta aceptada
Chunru
el 8 de Jun. de 2021
One workaround is to delete the NodeLabel and use text (and then you can control the position):
ax.NodeLabel={};
htext = text(ax.XData, ax.YData, NodeLabels, 'HorizontalAlignment', 'center');
Más respuestas (0)
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!