cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
69 stars 15 forks source link

Set size of window/exported image #104

Closed nilsoberg closed 1 year ago

nilsoberg commented 1 year ago

By default, images exported by export_image are sized with a very wide width-height aspect ratio. I added code to hide the panels but that still doesn't change the aspect ratio. I would like something like 4:3. Is there a way to change the window size through the API (or in the back-end through a command-line argument to Cytoscape)?

bdemchak commented 1 year ago

Hi, Nils ...

I don't know of a way to get a 4:3 aspect ratio.

The first place I'd look would be the py4cytoscape documentation. The export_image() function has the zoom= parameter and the fit_content() function, neither of which affect the aspect ratio, though they can be used to include some nodes and not others ... or get the best fit of the network into the content window.

Next, I'd be looking at CyREST functions, which are what py4cytoscape calls to get stuff done. You can see these functions under the Swagger pages available via Cytoscape's Help | Automation menus. I don't see anything like what you're asking for.

I'm not aware of any internal Cytoscape functions that can change the Window size, which leaves Windows/MacOS calls. Seems like a ton of work, and portability would be an issue.

Rolling all the way back, given a .png or .jpg, is there trimming you could do after the fact??

It really seems like you would want to get Cytoscape's content window in the right aspect ratio, then apply a layout and (maybe) fit_content() and then the export_image(). Right??

If so, the question I can put to the Cytoscape developers would be how to get the content window's aspect ratio set up first.

Correct?

nilsoberg commented 1 year ago

I was using xvfb-run with Xwindow args on Linux to try to set the window size, and it doesn't work. I think you're right, looking into system APIs for changing window size seems unnecessary. As you have suggested, I use a large-ish Zoom, and then use a second script to crop white space out of the image.

Yes, you are correct about what I want. It would be nice to have a Cytoscape feature for exporting the image as a specific size rather than being forced to the current window aspect ratio.

bdemchak commented 1 year ago

OK ... I'll submit a feature request. Thanks.