Problem with biograph layout

조회 수: 1 (최근 30일)
n
n 2011년 2월 1일
I have problem with biograph layout. I went through the biograph object doc.
But my problem is with positioning nodes. I define node positions but when calling dolayout(bg,'Path', true) the places are different from the ones that I defined!? and when removing this and keeping dolayout(bg) before positioning (with e.g.: bg.nodes(7).Position=[50 200];) the pattern of my 28 nodes looks in the way that I defined but very small on a corner of the figure and the rest is empty. I think the size of the image is fixed according to auto display of the biograph and when repositioning, it keeps the previous size somehow!
In this condition the shapes of the nodes are not the one that I defined (circle); probably because not calling dolayout again. but they are not the default rectangles either, they are ellipses! so it seems to respond very unusual and not obeying any rules! I also tried bg.Scale and bg.LayoutScale too. Though when trying different combination of calling handles before, after, or in between dolayout each time you can get a new surprising layout of the nodes but still confused and can not produce the result that I want.
I don't know if this info would make any difference but my layout consists of 28 nodes with only 7 edges. so a lot of nodes are not connected and should be just there in a right position. I'll appreciate any information on that.

답변 (1개)

Lucio Cetto
Lucio Cetto 2011년 2월 1일
The layout engine will readjust the size of the page according with the positions of the nodes, so, if you are going to set the positions of the nodes yourself, you just need to use a similar scale to the one it is initially provided, for example:
% I create a random graph with 28 nodes:
bg = biograph(28);
% Display it in the GUI and get a handle
% back to work with it (this will use by default
% the hierarchical layout):
hbg = view(bg);
% Get an idea of what are the actual extents of
% the page in the GUI by looking at all the current
% node positions:
page_Size = max(cell2mat(arrayfun(@(x) get(x,'Position'),...
get(hbg,'Nodes'),'Uniform',false)))
% Place the nodes in a circular layout, in my graph
% page_size was around [1000,1000], so I will select a
% center at [500 500] and a radius of 300, this will keep
% the layout approximately in the same scale and I will
% not have to manually change the size of the nodes or
% the fonts:
radius = 300;
center = [500 500];
for i = 1:28
set(hbg.Nodes(i),'Position',...
[center(1)+radius.*sin((i*2*pi/28)),...
center(2)+radius.*cos((i*2*pi/28))])
end
% Now I can use dolayout:
dolayout(hbg,'pathsOnly',true)
HTH Lucio
  댓글 수: 1
n
n 2011년 2월 2일
Thanks for the reply but when running your code I get the error:
??? Error using ==> arrayfun
Unsupported ARRAYFUN input type: biograph.node
I think the problem was with my positioning formula; the states were too close to each other and therefore I guess the dolayout could not handle and produced its own!
Thank God it is fixed now. :)

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

카테고리

Help CenterFile Exchange에서 Bioinformatics Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by