jgraph icon indicating copy to clipboard operation
jgraph copied to clipboard

Force Directed Layout Restricted to 2D Plane

Open fredhohman opened this issue 8 years ago • 3 comments

Is there a way to run the force directed graph layout on a graph but restrict the layout to 2D, say in the x-y plane?

i.e. just the standard layout technique found in other graph plotting packages.

Thanks!

fredhohman avatar Mar 03 '17 04:03 fredhohman

From here, jgraph.generate has an is_3d parameter. If you set that to False, it should generate a 2D graph.

patrickfuller avatar Mar 06 '17 14:03 patrickfuller

Perfect, got it working. Is there any way to have this work with jgraph.draw() in order to preserve the animation of the nodes moving into a steady state (e.g. the optimize parameter)?

fredhohman avatar Mar 08 '17 03:03 fredhohman

Doing it client side (so you see the animations) would require stripping out a few lines from this javascript function. You might be able to overwrite from the notebook with something like:

from IPython.display import Javascript
Javascript('jgraph.optimize = function () { # new function here }')

Alternately, you could write your own 3d toggle option in the javascript file and then submit a PR with the change.

patrickfuller avatar Mar 08 '17 04:03 patrickfuller