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 ...
随机推荐
- hdu 1254 推箱子(嵌套搜索,bfs中有dfs)
推箱子 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- dotnet 设计规范 · 结构体定义
X 不要给结构体默认构造函数 默认的C#编译器也不让开发者定义有默认构造的结构体 X 不要定义易变的属性 易变的属性指的是在调用属性返回值的时候返回的是新的实例,易变的属性会有很多的问题. ✓ 需要确 ...
- (超级详细版)利用ThinkPHP3.2.3+PHPExcel实现将表格数据导入到数据库
请先阅读以下步骤再到结尾下载源码 第一步:下载 thinkphp_3.2.3 和 PHPExcel_1.8.0 并解压 对应的网站分别为: http://www.thinkphp.cn/down.ht ...
- SpringSecurity认证流程详解
SpringSecurity基本原理 在之前的文章<SpringBoot + Spring Security 基本使用及个性化登录配置>中对SpringSecurity进行了简单的使用介绍 ...
- Tomcat最佳线程数
什么是最佳线程数? 为满足更多用户访问需求,可以调整Tomcat线程数,但是不能太大,否则导致线程切换开销,随着用户递增(线程数也随之调整),系统QPS逐渐增加,当用户量达到某个值,QPS并不会增加, ...
- P1049 找第K大的数
题目描述 给定一个无序正整数序列, 以及另一个数n (1<=n<=1000000), 然后以类似快速排序的方法找到序列中第n大的数(关于第n大的数:例如序列{1,2,3,4,5,6}中第3 ...
- H3C端口绑定技术简介
- 【HTML/CSS】置换元素
置换元素: 一个内容不受CSS视觉格式化模型控制,CSS渲染模型并不考虑对此内容的渲染,且元素本身一般拥有固有尺寸(宽度,高度,宽高比)的元素,被称之为置换元素. 行内级置换和非置换元素的宽度定义 对 ...
- TransactionDefinition接口中定义了七个事务传播行为
1.PROPAGATION_REQUIRED如果存在一个事务,则支持当前事务,如果没有事务则开启一个新的事务.使用spring声明式事务,spring使用AOP来支持声明式事务,会根据事务属性,自动在 ...
- oracle中update语句修改多个字段
如需要修改下列数据:表名为student 一般会这样写: update student set sname = '李四', sage = 20, sbirthday = to_date('2010-0 ...