Hello,
Is there any one knows how to change the font size of node name in a graph, please!
I see that we can change many graphical characteristics by using the option 'Edit', but I can not find any option to change the font size of node names.
Could you help me, please!
Thanks,
Khuyen

 채택된 답변

Josh Meyer
Josh Meyer 2019년 3월 20일

3 개 추천

Several new properties were added to GraphPlot objects in R2018b to enable customization of node and edge labels. In particular you can change the font size with the NodeFontSize and EdgeFontSize properties.
A list of all the properties is here: GraphPlot Properties
Example:
G = graph([1 1 1 1 5 5 5 5],[2 3 4 5 6 7 8 9]);
h = plot(G,'NodeLabel',{'A','B','C','D','E','F','G','H','I'});
h.NodeFontSize = 14;

댓글 수: 4

Le Thi Khuyen
Le Thi Khuyen 2019년 3월 20일
Thanks for your answer. Unfortunately I can not do this for Matlab version R2018a. :-(
Correct, in R2018a you can't use the new properties.
One workaround for older releases would be to use a text object to add labels to the plot, since text objects allow you to customize the text with NV pairs. The XData and YData properties of the GraphPlot object have the x,y coordinates of the nodes.
G = graph([1 1 1 1 5 5 5 5],[2 3 4 5 6 7 8 9]);
h = plot(G,'NodeLabel',{});
t = text(h.XData,h.YData,{'A','B','C','D','E','F','G','H','I'},'FontSize',14)
Le Thi Khuyen
Le Thi Khuyen 2019년 3월 20일
It works very well. Thank you so much!
Souarv De
Souarv De 2021년 4월 8일
This is not available in R2018a.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

2019년 3월 17일

댓글:

2021년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by