graphviz 的使用教程
node 节点属性如下 :
Name | Default | Values |
---|---|---|
color | black | node shape color |
comment | any string (format-dependent) | |
distortion | 0.0 | node distortion for shape=polygon |
fillcolor | lightgrey/black | node fill color |
fixedsize | false | label text has no affect on node size |
fontcolor | black | type face color |
fontname | Times-Roman | font family |
fontsize | 14 | point size of label |
group | name of node’s group | |
height | .5 | height in inches |
label | node name | any string |
layer | overlay range | all, id or id:id |
orientation | 0.0 | node rotation angle |
peripheries | shape-dependent | number of node boundaries |
regular | false | force polygon to be regular |
shape | ellipse | node shape; see Section 2.1 and Appendix E |
shapefile | external EPSF or SVG custom shape file | |
sides | 4 | number of sides for shape=polygon |
skew | 0.0 | skewing of node for shape=polygon |
style | graphics options, e.g. bold, dotted, filled; cf. Section 2.3 | |
URL | URL associated with node (format-dependent) | |
width | .75 | width in inches |
z | 0.0 | z coordinate for VRML output |
edge 边框属性如下:
Name | Default | Values |
---|---|---|
arrowhead | normal | style of arrowhead at head end |
arrowsize | 1.0 | scaling factor for arrowheads |
arrowtail | normal | style of arrowhead at tail end |
color | black | edge stroke color |
comment | any string (format-dependent) | |
constraint | true | use edge to affect node ranking |
decorate | if set, draws a line connecting labels with their edges | |
dir | forward | forward, back, both, or none |
fontcolor | black | type face color |
fontname | Times-Roman | font family |
fontsize | 14 | point size of label |
headlabel | label placed near head of edge | |
headport | n,ne,e,se,s,sw,w,nw | |
headURL | URL attached to head label if output format is ismap | |
label | edge label | |
labelangle | -25.0 | angle in degrees which head or tail label is rotated off edge |
labeldistance | 1.0 | scaling factor for distance of head or tail label from node |
labelfloat | false | lessen constraints on edge label placement |
labelfontcolor | black | type face color for head and tail labels |
labelfontname | Times-Roman | font family for head and tail labels |
labelfontsize | 14 | point size for head and tail labels |
layer | overlay range | all, id or id:id |
lhead | name of cluster to use as head of edge | |
ltail | name of cluster to use as tail of edge | |
minlen | 1 | minimum rank distance between head and tail |
samehead | tag for head node; edge heads with the same tag are | |
sametail | merged onto the same port | |
style | tag for tail node; edge tails with the same tag are merged onto the same port | |
taillabel | graphics options, e.g. bold, dotted, filled; cf. Section 2.3 | |
tailport | label placed near tail of edge n,ne,e,se,s,sw,w,nw | |
tailURL | URL attached to tail label if output format is ismap | |
weight | 1 | integer cost of stretching an edge |
Digraph 图属性如下:
Name | Default | Values |
---|---|---|
bgcolor | background color for drawing, plus initial fill color | |
center | false | center drawing on page |
clusterrank | local | may be global or none |
color | black | for clusters, outline color, and fill color if fillcolor not defined |
comment | any string (format-dependent) | |
compound | false | allow edges between clusters |
concentrate | false | enables edge concentrators |
fillcolor | black | cluster fill color |
fontcolor | black | type face color |
fontname | Times-Roman | font family |
fontpath | list of directories to search for fonts | |
fontsize | 14 | point size of label |
label | any string | |
labeljust | centered | ”l” and ”r” for left- and right-justified cluster labels, respectively |
labelloc | top | ”t” and ”b” for top- and bottom-justified cluster labels, respectively |
layers | id:id:id… | |
margin | .5 | margin included in page, inches |
mclimit | 1.0 | scale factor for mincross iterations |
nodesep | .25 | separation between nodes, in inches. |
nslimit | if set to f, bounds network simplex iterations by (f)(number of nodes) when setting x-coordinates | |
nslimit1 | if set to f, bounds network simplex iterations by (f)(number of nodes) when ranking nodes | |
ordering | if out out edge order is preserved | |
orientation | portrait | if rotate is not used and the value is landscape, use landscape orientation |
page | unit of pagination, e.g. “8.5,11” | |
pagedir | BL | traversal order of pages |
quantum | if quantum ¿ 0.0, node label dimensions will be rounded to integral multiples of quantum | |
rank | same, min, max, source or sink | |
rankdir | TB | LR (left to right) or TB (top to bottom) |
ranksep | .75 | separation between ranks, in inches. |
ratio | approximate aspect ratio desired, fill or auto | |
remincross | if true and there are multiple clusters, re-run crossing minimization | |
rotate | If 90, set orientation to landscape | |
samplepoints | 8 | number of points used to represent ellipses and circles on output (cf. Appendix C |
searchsize | 30 | maximum edges with negative cut values to check when looking for a minimum one during network simplex |
size | maximum drawing size, in inches | |
style | graphics options, e.g. filled for clusters | |
URL | URL associated with graph (format-dependent) |
from graphviz import Graph
from graphviz import Digraph # 绘制无向图
def draw_Graph():
# 创建对象,设置对象属性
dot = Graph(name='无向图', filename=r'D:\Cache\python\无向图', format='png')
# 设置节点属性, 修改 fontname 属性可解决中文输出乱码问题
dot.node_attr.update(shape='ellipse', color='black', fillcolor='lightgrey', fontcolor='black', fontsize='',
fontname='Microsoft YaHei', width='', height='', style='bold')
# 创建节点, 设置节点名字、内容
dot.node('A', '小朋友')
dot.node('B', '小学生')
dot.node('C', '初中生')
dot.node('D', '高中生')
dot.node('E', '大学生')
dot.node('F', '研究生')
dot.node('G', '博士生')
dot.node('H', '医生')
dot.node('I', '老师')
dot.node('J', '程序员')
dot.node('K', '会计')
dot.node('L', '公务员')
dot.node('M', '教授')
# 设置边属性
dot.edge_attr.update(color='black', fontcolor='black', fontsize='', fontname='Microsoft YaHei')
# 创建单边,设置边内容
dot.edge('A', 'B', '升级')
dot.edge('B', 'C', '升级')
dot.edge('C', 'D', '升级')
dot.edge('D', 'E', '升级')
dot.edge('E', 'F', '升级')
dot.edge('F', 'G', '升级')
# 创建多边,不能设置边内容
dot.edges(['EI', 'FI', 'GI', 'FH', 'GH', 'EJ', 'FJ', 'GJ', 'EK', 'FK', 'GK', 'EL', 'FL', 'GL', 'GM'])
# 打印生成的源代码,pdf 格式无法打印
print(dot.source)
# 保存图片,不显示图片
dot.render(filename='无向图', directory=r'D:\Cache\python')
# 保存图片,并显示图片
dot.view(filename='无向图', directory=r'D:\Cache\python') # 绘制有向图
def draw_Digraph():
# 创建对象,设置对象属性
dot = Digraph(name='有向图', filename=r'D:\Cache\python\有向图', format='pdf')
# 设置节点属性, 修改 fontname 属性可解决中文输出乱码问题
dot.node_attr.update(shape='ellipse', color='black', fillcolor='lightgrey', fontcolor='black', fontsize='',
fontname='Microsoft YaHei', width='', height='', style='bold')
# 创建节点, 设置节点名字、内容
dot.node('A', '小朋友')
dot.node('B', '小学生')
dot.node('C', '初中生')
dot.node('D', '高中生')
dot.node('E', '大学生')
dot.node('F', '研究生')
dot.node('G', '博士生')
dot.node('H', '医生')
dot.node('I', '老师')
dot.node('J', '程序员')
dot.node('K', '会计')
dot.node('L', '公务员')
dot.node('M', '教授')
# 设置边属性, arrowhead 为前端箭头样式, arrowsize 为箭头缩放比例, minlen 为边头部和尾部的距离, pnewidth 为边宽度
dot.edge_attr.update(color='black', fontcolor='black', fontsize='', fontname='Microsoft YaHei',
arrowhead='diamond', arrowsize='2.0', minlen='', penwidth='', style='dashed')
# 创建单边,设置边内容
dot.edge('A', 'B', '升级')
dot.edge('B', 'C', '升级')
dot.edge('C', 'D', '升级')
dot.edge('D', 'E', '升级')
dot.edge('E', 'F', '升级')
dot.edge('F', 'G', '升级')
# 创建多边,不能设置边内容
dot.edges(['EI', 'FI', 'GI', 'FH', 'GH', 'EJ', 'FJ', 'GJ', 'EK', 'FK', 'GK', 'EL', 'FL', 'GL', 'GM'])
# 保存图片,不显示图片
dot.render(filename='有向图', directory=r'D:\Cache\python')
# 保存图片,并显示图片
dot.view(filename='有向图', directory=r'D:\Cache\python') if __name__ == '__main__':
draw_Graph()
graphviz 的使用教程的更多相关文章
- 转+更新 Graphviz 教程,例子+ 高级应用 写代码,编程绘制架构图(分层拓扑图) 转自官网
1. Graphviz介绍 Graphviz是大名鼎鼎的贝尔实验室的几位牛人开发的一个画图工具. 它的理念和一般的“所见即所得”的画图工具不一样,是“所想即所得”. Graphviz提供了dot语言来 ...
- 用doxygen+graphviz自动化生成代码文档(附详细教程)
一.引子 用这两个工具可以自动的遍历代码,并且产生代码文档,我们先来看看效果,然后放出这两个工具的下载地址. 二.工具的下载地址 doxygen:http://www.stack.nl/~dimitr ...
- windows下Graphviz安装及入门教程
下载安装配置环境变量 intall 配置环境变量 验证 基本绘图入门 graph digraph 一个复杂的例子 和python交互 发现好的工具,如同发现新大陆.有时,我们会好奇,论文中.各种专业的 ...
- graphviz 布局和子图,表格教程
有了这三个利器,就搞定架构图了. 子图间互相调用要开启 http://graphviz.org/pdf/dotguide.pdf
- graphviz layer 教程(非布局)
官方 pdf 上讲解的很少,没有图片. http://www.graphviz.org/wiki/how-use-drawing-layers-overlays 这里有图片,但是又没有说如何生成. 直 ...
- 开启基本数据结构和算法之路--初识Graphviz
在我的Linux刀耕开荒阶段,就想开始重拾C,利用C实现常用的基本数据结构和算法,而数据结构和算法的掌握的熟练程度正是程序的初学者与职业程序员的分水岭. 那么怎么开启这一段历程呢? 按照软件工程的思想 ...
- 使用 Graphviz 画拓扑图
使用 Graphviz 画拓扑图 0)前述 本文着重讲一下 Graphviz 的风格控制,基础一些的就不在这里讲啦. graphviz 的主页是http://www.graphviz.org/. Gr ...
- KinectV1+Ubuntu 14.04安装教程
前言 个人理解错误的地方还请不吝赐教,转载请标明出处,内容如有改动更新,请看原博:http://www.cnblogs.com/hitcm/ 如有任何问题,feel free to ...
- 代码文档生成工具-Doxygen生成CHM和RTF图文教程
Doxygen是一种开源跨平台的,以类似JavaDoc风格描述的文档系统,可以从一套归档源文件开始,生成chm格式的文档.本文主要讲解如何在winddows下安装doxygen. 1.下载do ...
随机推荐
- Python--day23--初识面向对象复习
面向对象编程是大程序编程思想:
- Laravel 5.* 执行seeder命令出现错误的解决方法
最近在使用Laravel开发一个项目,测试中需要增加数据库基础数据动作,当第一次执行完`php artisan db:seed` 后,增加新的seeder文件时执行会报错.错误信息如下`[Reflec ...
- 2018-8-10-C#-代码占用的空间
title author date CreateTime categories C# 代码占用的空间 lindexi 2018-08-10 19:16:52 +0800 2018-2-13 17:23 ...
- java UDP传输
①:只要是网络传输,必须有socket . ②:数据一定要封装到数据包中,数据包中包括目的地址.端口.数据等信息. 直接操作udp不可能,对于java语言应该将udp封装成对象,易于我们的使用,这个对 ...
- linux并口纵览
因为我们期望大部分读者以所谓的"个人计算机"的形式使用一个 x86 平台, 我们觉得值 得解释一下 PC 并口如何设计的. 并口是在个人计算机上运行数字 I/O 例子代码的外设 接 ...
- js三大框架出现的意义
解决了原始html,css,js的UI与数据状态之间同步的难题,避免了大量的操作DOM代码. 使用了React,Angular和Vue,我们只需要定义一次 UI 界面,不再需要为每个操作编写特定的 U ...
- SpringBoot的四种定时任务
定时任务实现的几种方式: Timer:这是java自带的java.util.Timer类,这个类允许你调度一个java.util.TimerTask任务. 使用这种方式可以让你的程序按照某一个频度执行 ...
- java.util.Date和jdk1.8新时间API比拼
旧的时间和日期的API的缺陷 Java 的 java.util.Date 和 java.util.Calendar 类易用性差,不支持时区,而且都不是线程安全的. Date如果不格式化,打印出的日期可 ...
- Linux 内核 嵌入的 kobjects
在我们进入细节前, 值得花些时间理解如何使用 kobjects. 如果你回看被 kobjects 处 理的函数列表, 你会看到它们都是代表其他对象进行的服务. 一个 kobject, 换句话说, 对其 ...
- 在Linux中执行.sh脚本,异常/bin/sh^M
在Linux中执行.sh脚本,异常/bin/sh^M 在linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分 ...