How to wrap text in biograph nodes
이전 댓글 표시
I've been trying to make my node IDs in a biograph be multiline or wrap to a second line.
I can use the set() command to edit the node property 'ID'. However, every trick I try to get multiline text fails. the control character \n gets replaced with a space instead of causing a new line due to the verifyUniqueID operation used when the biograph is constructed. Thus, char('line 1','line 2') or sprintf('line 1\nline2') turn into 'line 1 line2'.
e.g.
% create biograph
d = biograph([0 1;0 0],{'Node A' 'Node B'};
hd = view(d)
% attempt to write a 2-line node ID
set(hd.Nodes(1),'ID',sprintf('Node A\nLine2')
set(hd.Nodes(2),'ID',sprintf('Node B\nLine2')
% refresh the biograph to reflect the changes
dolayout(hd)
I have additionally tried e.g. char('Node A','Line 2') as well as ['Node A';'Line 2']. My last resort is to modify the matlab function ... \toolbox\bioinfo\bioinfo\@biograph\@node\schema.m to attempt to block the verifyUniqueID
Maybe someone has an alternative approach that forces the text to wrap?
댓글 수: 11
Oleg Komarov
2012년 3월 22일
Does {'Node A';'Node B'} work?
Gregory
2012년 3월 22일
Oleg Komarov
2012년 3월 22일
What about:
d = biograph([0 1;0 0],{['Node A';'Line1 '], ['Node B';'Line2 ']};
Gregory
2012년 3월 23일
Oleg Komarov
2012년 3월 23일
Unfortunately I don't have the Bionformatics toolbox and I can't tweak the figure (since I can't create it). Try writing to the technical support. Good luck.
Geoff
2012년 3월 23일
Interesting... That cellfun() call looks like the one that removes newlines and other characters from your node names. The error message suggests to me that you can't give it an array of strings for each name.
Gregory
2012년 3월 23일
Gregory
2012년 3월 23일
Geoff
2012년 3월 23일
You should definitely entertain the notion that the code to draw and position those labels might not be able to cope with multiple lines, and that could be why they are explicitly removed. But it's good to try. Rather than modify the biograph code, are you able to tamper with the resulting object?
Gregory
2012년 3월 23일
Gregory
2012년 3월 23일
답변 (1개)
Gregory
2012년 3월 23일
0 개 추천
댓글 수: 2
Oleg Komarov
2012년 3월 23일
I suggest also to request technical support an enhancement to allow multiline nodes.
dan halbersberg
2016년 1월 28일
Can you be more specific on how to change the text within a node to include multi-lines? graph=biograph(dag,names);
g=biograph.bggui(graph);
f=figure;
copyobj(g.biograph.hgAxes,f);
f=get(g.biograph.hgAxes,'parent');
what's next? how do I access Nodes(1).ID from here and set it to: sprintf('Node A\nLine 2')?
카테고리
도움말 센터 및 File Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!