svg hiveplot python api

pyveplot的Python项目详细描述


一种可视化复杂网络的好方法是Hiveplots

这个库使用svgwrite来 以编程方式创建这样的图像:

https://github.com/CSB-IG/pyveplot/raw/master/example.png

一个简短的例子

< P>从一个网络中创建一个图,随机选择任意一个轴来放置50个节点。
from pyveplot import *
import networkx, random

# a network
g = networkx.barabasi_albert_graph(50, 2)

# our hiveplot object
h = Hiveplot( 'short_example.svg')
            # start      end
axis0 = Axis( (200,200), (200,100), stroke="grey")
axis1 = Axis( (200,200), (300,300), stroke="blue")
axis2 = Axis( (200,200), (10,310),  stroke="black")

h.axes = [ axis0, axis1, axis2 ]

# randomly distribute nodes in axes
for n in g.nodes():
    node = Node(n)
    random.choice( h.axes ).add_node( node, random.random() )

for e in g.edges():
    if (e[0] in axis0.nodes) and (e[1] in axis1.nodes):       # edges from axis0 to axis1
        h.connect(axis0, e[0], 45,
                  axis1, e[1], -45,
                  stroke_width='0.34', stroke_opacity='0.4',
                  stroke='purple')
    elif (e[0] in axis0.nodes) and (e[1] in axis2.nodes):     # edges from axis0 to axis2
        h.connect(axis0, e[0], -45,
                  axis2, e[1], 45,
                  stroke_width='0.34', stroke_opacity='0.4',
                  stroke='red')
    elif (e[0] in axis1.nodes) and (e[1] in axis2.nodes):     # edges from axis1 to axis2
        h.connect(axis1, e[0], 15,
                  axis2, e[1], -15,
                  stroke_width='0.34', stroke_opacity='0.4',
                  stroke='magenta')

h.save()
https://github.com/CSB-IG/pyveplot/raw/master/short_example.png

更精致的example.py 演示如何对节点使用形状、控制点的位置、边的属性以及属性 轴的数量。

安装

安装库,可能在virtualenv中:

$ pip install pyveplot

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javagae/JPA/Datastore如何查询无主列表   java从xml中读取未知元素   java如何在控制台上显示MavReplugin单元测试覆盖率报告   java什么被认为是遍历LDAP DIT的正确方法?   Eclipse(Java)在创建了一个新包之后,我无法向其中添加源文件   java new REngine启动并立即停止   java Android:如何从保存在SQLite数据库中的listview中删除项目?   找不到java Gradle DSL方法:“compile()”错误   java使用POI获取具有特定列名的每一行中的值   java解析JSON文件   java中断for循环,返回4个结果,而不是2个   LDAP处理过程中发生java未分类异常;嵌套的异常是javax。命名。NamingException   当表单在基于spring3注释的控制器中验证失败时,java引用数据将丢失   java Android,从web获取数据并更新UI(多线程和MVC设计模式)   用于OS X Yosemite的java优化Swing程序