I am using NetworkX and matplotlib to draw graph with png images as nodes. Here is my code:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.DiGraph()
#DRAWING EDGES ON AXIS
G.add_edges_from(([1,2],[3,4],[5,6],[7,8]))
pos = nx.circular_layout(G)
fig = plt.figure(figsize=(20, 20))
ax = plt.axes([0, 0, 15, 15])
ax.set_aspect('equal')
nx.draw_networkx_edges(G, pos, ax=ax, arrows=True)
#TRANSFORMING COORDINATES
trans = ax.transData.transform
trans2 = fig.transFigure.inverted().transform
#PUTTING IMAGE INSTEAD OF NODES
size = 0.2
p2 = size / 2.0
for n in G:
xx, yy = trans(pos[n])
xa, ya = trans2((xx, yy))
a = plt.axes([xa - p2, ya - p2, size, size])
a.set_aspect('equal')
a.imshow(image, aspect='auto')
a.axis('off')
plt.savefig('save.png')
plt.show()
Jupyter notebook displays graph. However, when I use Pycharm it shows blank white figure. Saving by plt.savefig() also do not works. I tried to play with dpi in plt.savefig() but doesn't change anything. Will be very grateful for any clues.