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.



--
View this message in context: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Annotating-graph-tool-graphs-with-graph-draw-as-a-matplotlib-subplot-tp4026936p4026938.html
Sent from the Main discussion list for the graph-tool project mailing list 
archive at Nabble.com.
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to