These are chat archives for ipython/ipython

7th
Apr 2018
Szabolcs Horvát
@szhorvat
Apr 07 2018 10:21

I am trying to make a custom formatter for networkx graphs, but I hit a few roadblocks. (I'm not experienced with Python).

I managed to get something working by having a function format_graph to plot a graph as a side effect, then using

get_ipython().display_formatter.ipython_display_formatter.for_type(nx.Graph, format_graph)
The problem with this is that I do not know how to simply not format graphs when they are too large.

There's another way, as described here: http://ipython.readthedocs.io/en/stable/config/integrating.html

I assume I need to implement a PNG formatter. But I do not know what kind of object the function should return so that it can be recognized as a PNG.