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 ...
随机推荐
- Django OMR QuerySet的特性/存在意义
QuerySet存在的意义主要在惰性机制和缓存两点 ---------->惰性机制: 所谓惰性机制:Publisher.objects.all()或者.filter()等都只是返回了一个Quer ...
- vue样式加scoped后不能覆盖组件的原有样式解决方法
<style scoped> </style> 为了vue页面样式模块化,不对全局造成污染,建议每个页面的style标签加上scoped,表示他的样式只属于当前的页面,父组件的 ...
- P1028 过河问题
题目描述 为了躲避黑暗大魔王的追杀,zifeiy与他的伙伴们共N人连夜逃出了黑暗城堡,他们走到一条河的东岸边,想要过河到西岸.而东岸边有一条小船. 船太小了,一次只能乘坐两人.每个人都有一个渡河时间T ...
- 随机抽样 (numpy.random)
随机抽样 (numpy.random) 简单的随机数据 rand(d0, d1, ..., dn) 随机值 >>> np.random.rand(3,2) array([[ 0.14 ...
- dotnet core 获取 MacAddress 地址方法
本文告诉大家如何在 dotnet core 获取 Mac 地址 因为在 dotnetcore 是没有直接和硬件相关的,所以无法通过 WMI 的方法获取当前设备的 Mac 地址 但是在 dotnet c ...
- [HNOI2019]白兔之舞
memset0 多合一无聊题 mod k=t,并且k是p-1的约数 单位根反演石锤了. 所以直接设f[i]表示走i步的方案数, 然后C(L,i)分配位置,再A^i进行矩乘得到f[i] 变成生成函数F( ...
- 数据库java包
package com.hgkj.model.dao.impl; import java.sql.*; public class DBManager { private static final St ...
- nodejs的nvm与.net的dnvm使用对比
一.vm安装命令 nodejs的nvm安装命令: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.s ...
- Oracle Net Manager 的使用方法(监听的配置方法)
一,在服务端配置oracle端口 win+R 输入netca 弹出如下窗口后 选择监听程序配置,点击下一步 二.配置端口后使用Telnet工具调试端口是否联通 在命令行输入telnet 服务器ip ...
- 有限状态机FSM和层次状态机HSM
前言 就单片机而言,程序可以分为两类:带操作系统的程序和前后台程序:前后台程序从架构上又分为顺序机和状态机. 广义地说, 任何一个程序都是一个状态机, 因为它总是要记住一些状态, 然后根据输入进行输出 ...