Comment utiliser python nrtworkx pour agrandir l'image ?
ringa_lee
ringa_lee 2017-05-18 10:57:21
0
1
622

L'image générée est trop petite et ne peut pas voir clairement les connexions entre les nœuds. Elle est trop dense. J'espère qu'il peut y avoir une solution

.
# _*_ coding:utf-8 _*_
import matplotlib.pyplot as plt
import networkx as nx

G = nx.DiGraph()
#加载文件中边的关系
with open('bigdata.txt') as f:
    lines = f.readlines()
mylist = [line.strip().split() for line in lines]  

pos =nx.spring_layout(G)

outlist = []
for i in range(len(mylist)):
    a = mylist[i][0]
    for j in range(len(mylist[i])-1):
        outlist.append([a, mylist[i][j+1]])

#加载边
G.add_edges_from(outlist)
nx.draw(G, with_labels=True, node_size=200,width=0.3, node_color='r', alpha = 0.7, edge_color='black',edge_vmin=2,edge_vmax=3)

plt.savefig('test1.png')
plt.show()
ringa_lee
ringa_lee

ringa_lee

répondre à tous(1)
某草草

Il est recommandé d'utiliser d3py pour les diagrammes de réseau ou de définir la taille du canevas de matplotlib

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!