Plotted a graph, want to specify label position relative to node
조회 수: 4(최근 30일)
표시 이전 댓글
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.
채택된 답변
Chunru
2021년 6월 8일
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');
추가 답변(0개)
참고 항목
범주
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!