Node lablel overlaping Edge lable
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Node lablels are overlaping Edge lables , as per the attached photo , what can i do to avoide that situation , also i wanna change the Node lable to be on the center of the Node not on the right of it
4 comentarios
Respuestas (1)
Kausthub
el 14 de Sept. de 2023
Hi Mohamed,
I understand that while plotting the graph, the edge labels are overlapping, and you would like to align the node labels to the centre instead of right alignment.
The overlapping error occurs due to the “Adjusting Xdata and YData to show Feeders separately” step where you assign the same Xdata to multiple nodes.
h.XData(:,id)= startxdata;
Instead, you could add a small random number to Xdata to make all the edges visible and remove the overlapping.
h.XData(:,id)= startxdata + 100*rand(1);
In case of aligning the nodes to the centre, there is a no documented property of ‘GraphPlot’ (https://www.mathworks.com/support/search.html/answers/477770-is-it-possible-to-change-the-position-of-graph-plot-node-labels.html) that allows you to change the placement of the labels relative to the nodes. However, you could remove the labels and replace them with your own matching text labels. That way you have complete control over the placement of each label. The bellow mentioned snippet does this for you:
text(h.XData, h.YData, h.NodeLabel,...
'HorizontalAlignment', 'center', 'FontSize', 8);
h.NodeLabel={};
Here is a MATLAB Answer which addresses the issue of positioning the node labels: https://www.mathworks.com/support/search.html/answers/477770-is-it-possible-to-change-the-position-of-graph-plot-node-labels.html
I am also attaching the updated code for better understanding.
Hope this helps and clarifies your issue regarding overlapping node labels and aligning them to the centre!
0 comentarios
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!