ipycytoscape icon indicating copy to clipboard operation
ipycytoscape copied to clipboard

Adjust the height of output graphs

Open tmontana opened this issue 4 years ago • 3 comments

Hi. I have a graph with many nodes and I'd like to be able to see it in full. by changing

out=widgets.Output(layout={'width': '800px', 'height': '800px','max_height':'100%', 'border': '1px solid black'}) out.display(cyto)

I get a bigger box for my graph but when I move the graph inside the box it gets cut in half (meaning the graph is limited to 400px no matter what). Is there a way to adjust this?

Thank you,

tmontana avatar Oct 09 '20 14:10 tmontana

Hey @tmontana good question! I don't think we mention how to do this at all in the docs so sorry about that.

The cytoscape object defines it's own dimensions in terms of pixels independent of it is parent element (in this case an output widget). Because the output widget and the cytoscape object are separate widget objects that don't really know how to talk to eachother changes will no propogate from one to the other. So you also need to modify the width and height. YOu can do that like so:

cyto.layout.height = '800px'
cyto.layout.width = '800px'

This strategy of setting object.layout.height I think will work for also most everything that is derived from an ipywidgetas the layout attribute is inherited from the widget superclass

ianhi avatar Oct 09 '20 15:10 ianhi

We should definitely include this in the docs. If anyone is interested in adding it I can help walk you through the process

ianhi avatar Oct 09 '20 15:10 ianhi

Hi ianhi. Works great now - Thanks a lot for the tip!

tmontana avatar Oct 09 '20 16:10 tmontana