0

I have tried this code for making an image to represent as node

from genericconnectionextraction import*
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img=mpimg.imread('N:\python\installed files\images\gnd.png')
g=nx.Graph()
for i in range(0,4):
    g.add_node(i,image=img)
nx.draw(g)
plt.show()

But,this still gives the red dots located at random positions(As i haven't gave any co-ordinates)

Many warnings are occurred after running the code. some are regarding python version like

axes.hold is deprecated, will be removed in 3.0

what is it all about?

  • In your command to draw the network, you don't give any instructions about what the node should look like, so it is using the default. – Joel Jun 05 '17 at 16:48
  • And the warnings you're getting are discussed a bit here: https://stackoverflow.com/questions/43263969/networkx-bug-with-matplotlib/43264755#43264755 (I just added a link with instructions for removing them to my answer there) – Joel Jun 05 '17 at 16:53
  • can u please elaborate the mistake in the command and give the correct line of code that is to be used brother to get image as node!! In draw command t.e nx.draw(g) I haven't used any instructions ri8, y is it wrong? – nikhil valiveti Jun 05 '17 at 17:50
  • Why would it be right? You've told it to draw `g`. So it's done that. You have additional constraints - you want the node to appear in a particular way, but `nx.draw(g)` says to use the default to draw the graph. You'll need to do more to tell it what to do. In order to help more, I would need to better understand what your desired output is. How should it appear? – Joel Jun 05 '17 at 22:51
  • My desired output for the present is just to get the 3 nodes as images rather than red dots, location is not specific. I would like to join those images with lines between (1,2),(2,3),(1,3) using networkx brother! Any help? **nx.draw(g,nodelist=[0,1,2],image=img)** even now its giving red dots only. Any help?@Joel – nikhil valiveti Jun 06 '17 at 04:53
  • take a look at https://groups.google.com/forum/#!topic/networkx-discuss/qhHjh0CGP8A or maybe https://stackoverflow.com/questions/33190985/substitute-node-labels-with-emoji-using-networkx-in-python, depending on what you're after. – Joel Jun 06 '17 at 07:44

0 Answers0