本文整理汇总了Python中networkx.draw_spring方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.draw_spring方法的具体用法?Python networkx.draw_spring怎么用?Python networkx.draw_spring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx
的用法示例。
在下文中一共展示了networkx.draw_spring方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_spring
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def draw_spring(self, **kwargs):
"""
Render a spring layout.
"""
nx.draw_spring(
self.graph,
with_labels=True,
font_size=10,
edge_color='#dddddd',
node_size=0,
**kwargs
)
plt.show()
示例2: test_draw
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def test_draw(self):
try:
N=self.G
nx.draw_spring(N)
plt.savefig("test.ps")
nx.draw_random(N)
plt.savefig("test.ps")
nx.draw_circular(N)
plt.savefig("test.ps")
nx.draw_spectral(N)
plt.savefig("test.ps")
nx.draw_spring(N.to_directed())
plt.savefig("test.ps")
finally:
try:
os.unlink('test.ps')
except OSError:
pass
示例3: test_draw
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def test_draw(self):
try:
functions = [nx.draw_circular,
nx.draw_kamada_kawai,
nx.draw_planar,
nx.draw_random,
nx.draw_spectral,
nx.draw_spring,
nx.draw_shell]
options = [{
'node_color': 'black',
'node_size': 100,
'width': 3,
}]
for function, option in itertools.product(functions, options):
function(self.G, **option)
plt.savefig('test.ps')
finally:
try:
os.unlink('test.ps')
except OSError:
pass
示例4: test_draw
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def test_draw(self):
try:
functions = [nx.draw_circular,
nx.draw_kamada_kawai,
nx.draw_random,
nx.draw_spectral,
nx.draw_spring,
nx.draw_shell]
options = [{
'node_color': 'black',
'node_size': 100,
'width': 3,
}]
for function, option in itertools.product(functions, options):
function(self.G, **option)
plt.savefig('test.ps')
finally:
try:
os.unlink('test.ps')
except OSError:
pass
示例5: test_edge_colormap
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def test_edge_colormap(self):
colors = range(self.G.number_of_edges())
nx.draw_spring(self.G, edge_color=colors, width=4,
edge_cmap=plt.cm.Blues, with_labels=True)
plt.show()
示例6: test_arrows
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def test_arrows(self):
nx.draw_spring(self.G.to_directed())
plt.show()
示例7: plot_graph
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import draw_spring [as 别名]
def plot_graph(self, ax=None):
"""
Plot the grid.
:param ax: Matplotlib axis object
:return:
"""
if ax is None:
fig = plt.figure()
ax = fig.add_subplot(111)
if self.graph is None:
self.build_graph()
nx.draw_spring(self.graph, ax=ax)