benmaier / netwulf

Interactive visualization of networks based on Ulf Aslak's d3 web app.
MIT License
294 stars 26 forks source link

POST picture back to Python such that it's shown in the Jupyter notebook, if one is used #8

Closed benmaier closed 5 years ago

benmaier commented 5 years ago

Post picture data to server

Display image in jupyter notebook

Find out wether the whole thing is running in a Jupyter notebook

benmaier commented 5 years ago

@ulfaslak yo, I wrote a function which reproduces the figure in matplotlib. see https://github.com/benmaier/netwulf/blob/master/netwulf/tools.py#L72

I also figured out a way to post the js-created png back to python, but I think it's nicer if we don't display the js-png but recreate the figure in matplotlib. That way, one can actually still do stuff with the figure and possibly save the whole thing as a PDF or what not. What do you think? Display js-png or redrawn matplotlib figure?

benmaier commented 5 years ago

Redrawing in matplotlib actually works great. However I have no doubt the posted picture should be available in the API somehow

ulfaslak commented 5 years ago

Sorry for reacting so slowly to this. I think the latter (matplotlib) solution is nicest! Especially because it enables exporting in vector format, which is a serious limitation is using canvas. So this kinda solves two problems at once :D!