Multiple lines in NodeLabel plot graph
2 次查看(过去 30 天)
显示 更早的评论
i used the following code to make a nodelabel string vector that contains information of the node , the information are divided into 3 strings , i joined the string and i add newline between them but on the plot the strings are next to each other , the newline doesn't apeare unlease the first string have charcters , please check the attached photo:
I want all my nodes to apear like the right amrked one , not the wrong marked
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1092310/image.jpeg)
and here is the code that i have used
strNodname=string(nameoflable);
strNodpower=string(poweroflable);
strNodeDP=string(connecteddp);
nodeslabletable=[strNodname,strNodpower,strNodeDP];
strnodeslabletable=join(nodeslabletable,newline,2)
h=plot(g,"EdgeLabel",edgelabletableinKM,"NodeLabel",strnodeslabletable,NodeLabelMode="manual",NodeFontName='Times New Roman' ...
,NodeFontAngle='italic',NodeFontWeight='bold',NodeFontSize=10)
0 个评论
回答(1 个)
Alan Baker
2023-6-8
Try using the char() function to vertically concatenate the strings for each node. The function adds spaces at the end of the sub-string to enforce equal length. In your example try:
strnodeslabletable ={ char('13 panel1', '500kVA', 'East...'), char('41 panel2-R', '500kVA','Kamel SS'), char('166500kVAKamelSS')};
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!