使用PyGraphviz在graph \ nodes上绘制更多信息 [英] Draw more information on graph\nodes using PyGraphviz

查看:64
本文介绍了使用PyGraphviz在graph \ nodes上绘制更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我想创建一个图形并绘制它,但是问题是我想在每个节点上绘制更多信息.我看到可以将属性保存到节点\边,但是如何绘制属性?我正在使用PyGraphviz,而女巫则使用Graphviz.

I want to create a graph and draw it, so far so good, but the problem is that i want to draw more information on each node. I saw i can save attributes to nodes\edges, but how do i draw the attributes? i'm using PyGraphviz witch uses Graphviz.

推荐答案

一个例子是

import pygraphviz as pgv
from pygraphviz import *
G=pgv.AGraph()
ndlist = [1,2,3]
for node in ndlist:
    label = "Label #" + str(node)
    G.add_node(node, label=label)
G.layout()
G.draw('example.png', format='png')

,但请确保您明确添加属性 label 以获得更多信息,以显示马丁提到的 https://stackoverflow.com/a/15456323/1601580 .

but make sure you explicitly add the attribute label for extra information to show as Martin mentioned https://stackoverflow.com/a/15456323/1601580.

这篇关于使用PyGraphviz在graph \ nodes上绘制更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆