dot language 学习笔记

UP | HOME

dot language 学习笔记

Table of Contents

  • 1 dot 语言简介
  • 2 基本语法
    • 2.1 常用图形
    • 2.2 常用线条
    • 2.3 常用箭头
    • 2.4 常用属性
      • 2.4.1 Node常用属性
      • 2.4.2 Edge常用属性
      • 2.4.3 Graph常用属性
    • 2.5 子图
    • 2.6 其他用法
      • 2.6.1 label使用html标签
      • 2.6.2 使用label定义子节点
  • 3 总结

1 dot 语言简介

DOT语言是一种文本图形描述语言。文件扩展名通常为.gv或.dot 。它可以导出的格式有:GIF、PNG、SVG、PDF及PostScript。

2 基本语法

2.1 常用图形

  • box、polygon、ellipse、circle、point、triangle、invtriangle、plaintext、diamond
digraph shapes {"Box"[shape=box]"Polygon"[shape=polygon,sides=7] /* 定义了一个7边行,sides属性定义多边形边的数量 */"Ellipse"[shape=ellipse]"Circle"[shape=circle]"Point"[shape=point]"triangle"[shape=triangle]"invtriangle"[shape=invtriangle]"plaintext"[shape=plaintext]"diamond"[shape=diamond]
}

想了解更多内容,那就点击我。

2.2 常用线条

  • 无向线条、又向线条、双向线条
digraph lines {"Undirected1"->"Undirected2"[arrowhead=none]"Undirected1"->"Directed1""Directed1"->"Directed2"[dir=both]
}

  • 实线、虚线、点线、加粗、透明
digraph lines2 {rankdir=LR"solid"->"dashed"[style=solid]"dashed"->"dotted"[style=dashed]"dotted"->"bold"[style=dotted]"bold"->"invis"[style=bold]"invis"->"solid"[style=invis]
}

2.3 常用箭头

  • box、crow、curve、icurve、diamond、dot、inv、none、normal、tee、vee
digraph arrow {rankdir=LR"box"->"crow"[arrowhead=box]"crow"->"curve"[arrowhead=crow]"curve"->"diamond"[arrowhead=curve]"diamond"->"dot"[arrowhead=diamond]"dot"->"inv"[arrowhead=dot]"inv"->"none"[arrowhead=inv]"none"->"normal"[arrowhead=none]"normal"->"tee"[arrowhead=normal]"tee"->"vee"[arrowhead=tee]"vee"->"box"[arrowhead=vee]#来个高级的用法a->b[arrowhead=lcrowortee]
}

想了解更多内容,那就点击我。

2.4 常用属性

2.4.1 Node常用属性

属性名 默认值 说明
color black node图形颜色,see color values
fontcolor black 字体颜色
fontname Times-Roman 字体
fontsize 14 字体大小
image   node背景图片地址
label node name node 显示内容
shape ellipse 形状
style   图形样式,eg. bold、dotted、filled
height .5 最低高度尺寸
width .75 最低宽度尺寸
URL   点击跳转地址
target   点击跳转打开方式
digraph demo_node {rankdir=LR"default_node""node"[shape=box,color=antiquewhite,style=filled,label="node attrs",fontcolor=brown,fontsize=10,URL="http://www.baidu.com",target="_brank"]"default_node"->"node"
}

2.4.2 Edge常用属性

属性名 默认值 说明
arrowhead normal 箭头样式
arrowsize 1.0 箭头尺寸
color black 颜色
dir forward 箭头方向
edgeURL   点击跳转地址
fontcolor black 字体颜色
fontname Times-Roman 字体
fontsize 14 字体大小
headport   线条头部连接处,eg.n、ne、e、se、s、sw、w、nw
label   描述内容
labelfontcolor black label字体颜色
labelfontname Times-Roman label字体
labelfontsize 14 label字体大小
style   图形样式,eg.bold、dotted、filled
tailport   线条尾部连接处,eg.n、ne、e、se、s、sw、w、nw
weight 1 integer cost of stretching an edge
digraph demo_edge {rankdir=LRa->b[label="Yes",labelfontcolor=blue]edge[arrowhead=box,arrowsize=1.5,color=red,dir=both,style=dotted,weight=10]b->c
}

2.4.3 Graph常用属性

属性名 默认值 说明
bgcolor   背景颜色
color black for clusters,outline color,and fill color
dpi 96 图像输出像素
fillcolor black cluster fill color
fontcolor black 字体颜色
fontname Times-Roman 字体
fontsize 14 字体大小
label   描述内容
landscape   true:orientation=landscape
rank   子图等级限制, same,min,max,source,sink
rankdir TB 图片排列方式,LR(left to right) or TB(top to bottom)
size   最大图片尺寸
style   图片样式
stylesheet   pathname or URL to XML style sheet for SVG
URL   点击跳转地址
target   点击跳转打开方式
digraph demo_graph {bgcolor=beigefontcolor=gray10fontsize=12label="this is demo"rankdir=TB{rank=same; "level1" "a-level1" "b-level1" "c-level1"}{rank=same; "level2" "d-level2" "e-level2"}{rank=same; "level3" "f-level3" "g-level3" "h-level3" "i-level3" "j-level3"}{rank=same; "level4" "k-level4"}"level1"->"level2"->"level3"->"level4""a-level1"->"d-level2""e-level2"->{"h-level3", "k-level4"}"b-level1"->{"e-level2", "f-level3", "i-level3", "k-level4"}"c-level1"->{"d-level2", "g-level3", "h-level3"}"j-level3"->{"f-level3", "k-level4"}
}

2.5 子图

dot支持将一组元素组合成一个子图,且一个图形可以包含一个及多个子图。
使用子图需要注意以下两点:

  • 子图node无法在主图rank中使用。
  • 子图命名必须以:"cluster"作为前缀。
digraph demo_subgraph {bgcolor=beigefontcolor=gray10fontsize=12label="this is demo"rankdir=TB/* 特别注意: 子图命名必须以"cluster"为前缀 */subgraph "cluster_g1" {label="g1"bgcolor=cadetblue"level1"->"level2"->"level3"->"level4"}subgraph "cluster_g2" {label="g2"bgcolor=cornsilk"level2""d-level2""e-level2"}subgraph "cluster_g3" {label="g3"bgcolor=cornsilk"level3""f-level3""g-level3""h-level3""i-level3""j-level3"}"a-level1"->"d-level2""e-level2"->{"h-level3", "k-level4"}"b-level1"->{"e-level2", "f-level3", "i-level3", "k-level4"}"c-level1"->{"d-level2", "g-level3", "h-level3"}"j-level3"->{"f-level3", "k-level4"}
}

2.6 其他用法

2.6.1 label使用html标签

digraph html {abc [shape=none, margin=0, label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"><TR><TD ROWSPAN="3"><FONT COLOR="red">hello</FONT><BR/>world</TD><TD COLSPAN="3">b</TD><TD ROWSPAN="3" BGCOLOR="lightgrey">g</TD><TD ROWSPAN="3">h</TD></TR><TR><TD>c</TD><TD PORT="here">d</TD><TD>e</TD></TR><TR><TD COLSPAN="3">f</TD></TR></TABLE>>];}

2.6.2 使用label定义子节点

digraph structs {node [shape=record];struct1 [shape=record,label="<f0> left|<f1> middle|<f2> right"];struct2 [shape=record,label="<f0> one|<f1> two"];struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];struct1:f1 -> struct2:f0;struct1:f2 -> struct3:here;
}

3 总结

通过这几天对dot语言的学习,发现它还是非常强大和灵活的。只要能够发挥你的组合及想象能力,肯定是能够满足一些基本文档图表的绘制需求。而且还摆脱了普通制图功能繁琐的排版工作,还是非常适合有一定编程基础的用户使用的。
个人非常厌恶繁琐的排版工作,因此emacs + org-mode + Graphviz会是以后书写文档的必备工具。
之后有时间在将ditaa及plantuml集成进来,毕竟用他们绘制一些专业图表还是更加快捷方便一些。


参考文献:
http://billnote.github.io/chenfanyu/archive/2013/01/27/2878845.html
http://coldnew.github.io/blog/2013/07/13_07e15.html
http://www.graphviz.org

Date: 2014-10-22T14:02+0800

Author: Billyhuang@sina.cn

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0

转载于:https://www.cnblogs.com/billnote/p/4043267.html

dot language 学习笔记相关推荐

  1. .NET/Dot Net学习笔记---.net理解,C#.net的基本类型,字符串转义字符处理..

    1.NET .Dot Net 基于.net的语言:C#,VB.Net,F#,IronPython 2.Visual Studio是开发工具,.NET Framework是提供的一些类库;所有基于.ne ...

  2. C# Programming Language学习笔记(三)

    第二章 词法结构 The lexical grammar defines how Unicode characters are combined to form line terminators, w ...

  3. 【我的DOT语言学习之旅】 学习DOT语言并使用Graphviz软件来打开.dot文件

    一.背景描述 最近在研究didi的booster框架,应用到项目中,然后通过执行 assemble task 来构建一个优化过的应用包,构建完成后,在 build/reports/ 目录下会生成相应的 ...

  4. 十分钟了解绘图神器——Graphviz学习笔记

    DOT语言学习笔记 设置点和线的形状与颜色 digraph是有向图,graph是无向图.要注意,->和–都表示图中的一条边,但是前者用于有向图中,而后者用于无向图中,不能混用. 代码示例 dia ...

  5. Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language

    Scipy Lecture Notes学习笔记(一)Getting started with Python for science 1.2. The Python language 1.2.2. 基本 ...

  6. Kusto Query Language (KQL) 学习笔记

    Kusto Query Language (KQL) 学习笔记 Kusto 是一种nosql,其有自身的查询语言规则,简称KQL. 学习笔记持续更新中,点击每个节点的小加号,展开小节内容 KQL学习笔 ...

  7. 《Python自然语言处理(第二版)-Steven Bird等》学习笔记:第05章 分类和标注词汇

    第05章 分类和标注词汇 5.1 使用词性标注器 5.2 标注语料库 表示已标注的标识 读取已标注的语料库 简化的词性标记集 名词 动词 形容词和副词 未简化的标记 探索已标注的语料库 5.3 使用P ...

  8. Android学习笔记:Android基础知识点(不断更新中)

    1.Android学习笔记:OkHttp 2.Android学习笔记:更新UI的方法(UI线程和非UI线程) 3.Android学习笔记:Volley 4.Android学习笔记:Handler 5. ...

  9. Apollo星火计划学习笔记——Apollo开放空间规划算法原理与实践

    文章目录 前言 1. 开放空间规划算法总体介绍 1.1 Task: OPEN_SPACE_ROI_DECIDER 1.2 Task: OPEN_SPACE_TRAJECTORY_PROVIDER 1. ...

  10. django系统学习笔记

    转自:http://hi.baidu.com/derris/item/7ca6013e330563fede2221ab 2010-02-07 00:12 django系统学习笔记--(1)hello ...

最新文章

  1. RDKit | RDKit 中的RECAP进行分子裂解
  2. Linux/windows系统定时任务调度总结
  3. React 15.5带来重大修改
  4. Caffe2:添加CUDA路径
  5. 算法设计之—常用算法之-分支界定法
  6. 修改GIT的user.name和user.email
  7. jmeter练习(5)关联升级版—ForEach控制器(提取多个响应结果并依次传参)
  8. java poi读取excel日期格式数据
  9. wampserver下修改mysql root用户的登录密码
  10. Windows Embedded Compact 7中的进程和线程(上)
  11. 思科网院Packet Tracer实验(二)IOS基本配置
  12. Spring、SpringMVC、SpringBoot、SpringCloud的联系与区别(看了多篇后的自我总结)
  13. VS2019/MFC学习笔记之一(创建对话框工程并实现简单加法运算)
  14. 皮尔逊相关系数和斯皮尔曼相关系数(等级系数)与典型相关分析
  15. 开源应用中心 | KodExplorer高效流畅云端存储协同办公新体验
  16. linux安装rmp格式文件,在CentOS Linux上使用yum、dnf和rpm安装RPM文件(Packages)
  17. 七夕表白代码合集,建议收藏!!!
  18. 广告牌定时器怎么设置时间_广告牌定时器时间到了灯箱不亮怎么回事?
  19. 自学白帽黑客第一年总结
  20. 数据挖掘导论课后习题答案-第七章

热门文章

  1. 自动垃圾回收学习笔记-我们为什么需要自动垃圾回收
  2. mysql安装手册(2)
  3. Docker 为什么输给了Kubernetes?Docker 员工自述!
  4. 放弃用了7年的MyBatis !我选择 JDBCTemplate!
  5. Intellij IDEA 看源码必备的技能!
  6. 浅谈web架构之架构设计
  7. Vim查找与替换命令大全,功能完爆IDE!
  8. 再送 5000 份红包封面!
  9. c语言文本编辑器源代码_程序员专属的10个免费编程文本编辑器,哪个是你的最爱?...
  10. Lintcode 553. 炸弹袭击 题解