Data Visualization - Dot Lang & Graphviz

Data Visualization - Dot Lang & Graphviz

Graphviz安装

依据官网http://www.graphviz.org/Download..php讲述的下载、安装方式进行。

Windows:
下载:http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.38.msi
以管理员权限运行 graphviz-x.xx.msi

Warning for Vista users: Even if you are logged in as adminstrator, double-clicking on the MSI file or running the MSI file from a command prompt may still not may not provide sufficient privileges. You have to run “msiexec /a graphviz-x.xx.msi”.1

配置环境变量,将X:\PATH_TO_Graphviz2.38\bin加入到PATH中

Note: As of version 2.31, the Visual Studio package no longer alters the PATH variable or accesses the registry at all. If you wish to use the command-line interface to Graphviz or are using some other program that calls a Graphviz program, you will need to set the PATH variable yourself.2

Redhat/Centos:
使用yum Repository
设置yum源 graphviz-rhel.repo 到 /etc/yum.repos.d/
执行安装

yum list available 'graphviz*'
yum install 'graphviz*'

或者下载各个组件的rpm安装包进行安装,参考http://www.graphviz.org/Download_linux_rhel.php

Ubuntu:
目前有一个graphviz开发版可用于apt-get 安装,参考https://launchpad.net/~gviz-adm/+archive/ubuntu/graphviz-dev
或者下载各个组件的deb安装包进行安装,参考http://www.graphviz.org/Download_linux_ubuntu.php

Anaconda (如果你使用Python则推荐这种方式):
不管是Linux, windows, osx操作系统,安装好anaconda之后运行

conda install -c anaconda graphviz=2.38.0

即可完成安装。

graphviz conda package 并不是 Python package,如果使用import graphviz则会报出” no module named graphviz “错误,这便是因为graphviz conda package 仅是将lib files放入了library/中,例如dot可以在”/PATH_TO_ANACONDA/bin/”目录中找到并执行。
如果要安装graphviz Python package, 使用”pip install graphviz”3

最近使用yum安装时出现错误
这里写图片描述
目前这个BUG已经被提交,还没有进一步更新。45

安装完成后执行

dot -version

显示graphviz相关的版本信息
这里写图片描述

还可以打开graphviz的编辑器gvedit

gvedit

这里写图片描述


DOT语言

DOT (graph description language)
DOT是一种用文本文件表示的图像描述语言,一般DOT文件以”gv”或者”dot”为后缀(”gv”的表示方式是用来跟早期(2007之前)的Microsoft Word区分)。6

Syntax

DOT 的抽象语法表达7

     graph  :   [ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'
 stmt_list  :   [ stmt [ ';' ] stmt_list ]
      stmt  :   node_stmt
            |   edge_stmt
            |   attr_stmt
            |   ID '=' ID
            |   subgraph
 attr_stmt  :   (graph | node | edge) attr_list
 attr_list  :   '[' [ a_list ] ']' [ attr_list ]
    a_list  :   ID '=' ID [ (';' | ',') ] [ a_list ]
 edge_stmt  :   (node_id | subgraph) edgeRHS [ attr_list ]
   edgeRHS  :   edgeop (node_id | subgraph) [ edgeRHS ]
 node_stmt  :   node_id [ attr_list ]
   node_id  :   ID [ port ]
      port  :   ':' ID [ ':' compass_pt ]
            |   ':' compass_pt
  subgraph  :   [ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt  :   (n | ne | e | se | s | sw | w | nw | c | _)

可以参考wiki中的几个例子来解释DOT语法。8
Undirected graphs (无向图)
Directed graphs (有向图)
Attributes (属性)
属性字典请参考:http://www.graphviz.org/content/attrs
Comments (注释)
更多示例可以参考:
http://blog.csdn.net/zhangskd/article/details/8250470
http://www.graphviz.org/Gallery.php

Layout programs

The DOT language defines a graph, but does not provide facilities for rendering the graph. There are several programs that can be used to render, view, and manipulate graphs in the DOT language:

Graphviz - A collection of libraries and utilities to manipulate and render graphs
Canviz - a JavaScript library for rendering dot files.
Viz.js - A simple Graphviz JavaScript client
Grappa - A partial port of Graphviz to Java.
Beluging - A Python & Google Cloud based viewer of DOT and Beluga extensions.
Tulip can import dot files for analysis
OmniGraffle can import a subset of DOT, producing an editable document. (The result cannot be exported back to DOT, however.)
ZGRViewer, a GraphViz/DOT Viewer link
VizierFX, A Flex graph rendering library link
Gephi - an interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs

未完待续……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值