On 01.01.2017 15:41, Steve wrote: > Thank you Tiago and feliz Ano Novo. > > I hope I'm not getting greedy here, but I'd like to get this inline within a > Jupyter Notebook. > > I have graph_draw(mplfig=) working outside of a Jupyter notebook, and > graph_draw itself works great inline within a Jupyter notebook. > > It should be possible to get both together to produce nice annotations of > graphs in a notebook. > > Based on this Stackoverflow thread > <http://stackoverflow.com/questions/34425955/make-coordinate-systems-agree-between-matplotlib-and-graph-tool> > > , this code works in straight iPython: > > >> # matplotlib with gt.graph_draw -- order important here >> import matplotlib as mpl >> mpl.use('cairo') >> # %matplotlib inline >> import matplotlib.pyplot as plt >> import graph_tool.all as gt # , graph_tool >> >> x = [0,1] >> y = [0,1] >> >> g = gt.Graph() >> pos = g.new_vertex_property('vector >> <float> >> ') >> v0 = g.add_vertex() >> v1 = g.add_vertex() >> e01 = g.add_edge(v0,v1) >> pos[v0] = [0,0] >> pos[v1] = [1,1] >> >> plt.plot(x,y) >> ax = plt.gca() >> gt.graph_draw(g, pos=pos, mplfig=ax) >> plt.savefig('test.png') > > But if I embed this code in a Jupyter notebook with the magic line > "%matplotlib inline" uncommented, I do not get inline graphics, -- only a > return object pointer. > > I'd greatly appreciate your thoughts if this Jupyter notebook capability > would/should be possible.
Sorry for the late reply. Graph-tool uses cairo for drawing, and hence it only interplays with matplotlib when a cairo-compatible backend is being used. I believe that with Jupyter notebooks a HTML canvas backend is used, which is not cairo... It may be possible to force matplotlib to use a cairo-based image backend instead, but I'm not sure. Best, Tiago -- Tiago de Paula Peixoto <[email protected]> _______________________________________________ graph-tool mailing list [email protected] https://lists.skewed.de/mailman/listinfo/graph-tool
