I am trying to use the output of the networkx.draw function, which is a collection (LineCollection), for use in matplotlib.animation, which requires an array. I do not want to save my figure as png, because there will be many of them. I also do not want to display it, but this is not critical.
A simple code could be:
import networkx as nx
graph= nx.complete_graph(5)
Drawing=nx.draw(graph)
python collection is output:
<matplotlib.collections.LineCollection at 0xd47d9d0>
I want to create a list of these drawings:
artists=[]
artists.append(Drawing)
And then use these pictures in the animation:
import matplotlib
fig= plt.figure()
anim=matplotlib.animation.ArtistAnimation(fig, artists,interval=50, repeat_delaty=1000)
However, I get a TypeError as shown below:
TypeError: 'LineCollection' object is not iterable
, , "" , , png-, - PIL ( ), , , png .
, : , im = plt.imshow(f(x, y)) , , :
TypeError: Image data can not convert to float
, , . - ?