Jump to content

Python Experts


Hindhustani

Recommended Posts

I think Below code generates visual graph , how to run the program in Mac? From command line execution it is not giving any visuals,  What are the options?

 

import networkx as nx
import matplotlib.pyplot as plt

G = nx.DiGraph()

G.add_node("John")
G.add_node("Jane")
G.add_node("Jim")

G.add_edge("John", "Jane")
G.add_edge("John", "Jim")

pos = nx.spring_layout(G)

nx.draw_networkx_nodes(G, pos, node_color='lightblue', node_size=1000)
nx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')
nx.draw_networkx_edges(G, pos, edge_color='gray')

plt.axis('off')
plt.show()

Link to comment
Share on other sites

25 minutes ago, Hindhustani said:

I think Below code generates visual graph , how to run the program in Mac? From command line execution it is not giving any visuals,  What are the options?

 

import networkx as nx
import matplotlib.pyplot as plt

G = nx.DiGraph()

G.add_node("John")
G.add_node("Jane")
G.add_node("Jim")

G.add_edge("John", "Jane")
G.add_edge("John", "Jim")

pos = nx.spring_layout(G)

nx.draw_networkx_nodes(G, pos, node_color='lightblue', node_size=1000)
nx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')
nx.draw_networkx_edges(G, pos, edge_color='gray')

plt.axis('off')
plt.show()

Ask chatgpt anna

Link to comment
Share on other sites

46 minutes ago, Hindhustani said:

I think Below code generates visual graph , how to run the program in Mac? From command line execution it is not giving any visuals,  What are the options?

 

import networkx as nx
import matplotlib.pyplot as plt

G = nx.DiGraph()

G.add_node("John")
G.add_node("Jane")
G.add_node("Jim")

G.add_edge("John", "Jane")
G.add_edge("John", "Jim")

pos = nx.spring_layout(G)

nx.draw_networkx_nodes(G, pos, node_color='lightblue', node_size=1000)
nx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')
nx.draw_networkx_edges(G, pos, edge_color='gray')

plt.axis('off')
plt.show()

https://stackoverflow.com/questions/2512225/matplotlib-plots-not-showing-up-in-mac-osx

Idhi choodu baa

 

 

Link to comment
Share on other sites

55 minutes ago, Hindhustani said:

I think Below code generates visual graph , how to run the program in Mac? From command line execution it is not giving any visuals,  What are the options?

 

import networkx as nx
import matplotlib.pyplot as plt

G = nx.DiGraph()

G.add_node("John")
G.add_node("Jane")
G.add_node("Jim")

G.add_edge("John", "Jane")
G.add_edge("John", "Jim")

pos = nx.spring_layout(G)

nx.draw_networkx_nodes(G, pos, node_color='lightblue', node_size=1000)
nx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')
nx.draw_networkx_edges(G, pos, edge_color='gray')

plt.axis('off')
plt.show()

Install VSCode n run ur code there

Or install Jupiter notebook and run it

 

Google how to do that

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...