I currently have to plot a lot of networks for my master thesis. Since the common graph tools for networks in julia (e.g. lightgraph, gplot, graphrecipes,…) are far from being as mature as python’s networkx is I decided to import networkx via PyCall.
using PyCall nx = pyimport("networkx")
Normally I use plots for plotting, but with Networkx I have to use PyPlot.
Is there a way to handle PyPlot figures with Plots? What I would like to do exactly is to create an animation from PyPlot figures with Plots, like:
using PyPlot using Plots pyplot() #change backend #create graph and get positional information g = nx.hexagonal_lattice_graph(3, 3) pos = nx.get_node_attributes(g, "pos") @gif for i in 1:100 PyPlot.figure() nodes = nx.draw_networkx_nodes(g, pos, node_color = [RGBA(0.0,0.0,rand(),1.0) for i in 1:nx.number_of_nodes(g)], cmap = PyPlot.get_cmap("twilight"), ) edges = nx.draw_networkx_edges(g, pos) PyPlot.colorbar(nodes) PyPlot.draw() end every 10
This gives me the Error message:
No current Plot/Subplot
Since I can use pyplot as backend for Plots, I thought this should be theoretically possible. Does anyone have an idea?
Another way to solve the problem would be to call PyPlot functions (like
draw()) in Plots. Is that possible?