My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
saveRestoreNodePositions  
Updated Apr 24, 2010 by mattbdun...@gmail.com

It is now possible to save and restore node positions using two new methods, getNodePositions() and setNodePositions():

adj = rand(10, 10) > 0.9; 
g = graphViz4Matlab(adj);
X = g.getNodePositions();
X(1, :) = [0.5 0.5]; 
g.setNodePositions(X)
  • Coordinates are normalized so that [0 0] is the bottom left hand corner, and [1 1] is the top right.
  • X(i, 1) is the x-position of the ith node, and X(i, 2) is its y position.
  • To move a single node, you can use g.moveNode(i, xpos, ypos);
  • Coordinates specify a node's center. You must take into account its current diameter to avoid moving it off the visible screen. This code moves node 1 to the bottom left corner.
diameter = g.nodeArray(1).width
radius = diameter/2;
g.moveNode(1, radius, radius); 

Sign in to add a comment
Powered by Google Project Hosting