graphviz

1.创建图
DOT中使用图(digraph/graph)、节点(node)和边(edge)来描述关系图/流程图。

digraph name1 {
    label = "graph";
    a;b;

    subgraph cluster_sgh {
        label = "subgraph";
        c;d;
    }
}

使用node []和edge []对全局进行设置

digraph graph1 {
    node [shape = circle];
    edge [style = dashed];

    a -> b;
}

这里写图片描述

2.图属性设置
图的属性设置可以写在graph []里,或者直接写在外面:

digraph graph1 {
    bgcolor = red;
    graph [bgcolor = red];
}
参数描述
bgcolor背景色,red、blue、green或者#十六位
lable图的title
rankdir设置图的方向。TB(top to bottom)、BT(bottom to top)、LR(left to right)、RL(right to left)
roteate旋转方向
ratio长宽比

这里写图片描述

3.节点属性设置
a [shape = egg, label = “this is node a”];

参数描述
shape形状。Mrecord(圆角矩形)、record(矩形)、circle(圆形)、box(矩形,和record略有区别,下面会讲到)、egg(蛋形)、doublecircle(双圆形)、plaintext(纯文本)、 ellipse(椭圆,默认)
label形状title,写在node里面
style设置样式。filled(填充)、dotted(点状边框)、solid(普通边框)、dashed(虚线边框)、bold(边框加粗)、invis(隐形)
color设置边框的颜色。
fillcolor设置填充颜色,要设置style=filled
width
height
peripheries节点边框个数
fontcolor节点的内容颜色

4.连线的属性

参数描述
stylesolid(实线)、dashed(虚线)、dotted(点线)、bold(加粗)、invis(隐形)
label边标签
color边的颜色
arrowhead箭头样式。none、empty、odiamond等

这里写图片描述

5.其他
设置中文字体

// 影响图片级别的字体
graph [fontname="宋体"];
// 影响节点中的文字字体
node [fontname="宋体"];
// 影响箭头或线条上的文字字体
edge [fontname="宋体"];

输出图片,指定字体

dot -Nfontname=simsun -Tpng graph2.gv -o sample.png

参考文献:
https://blog.csdn.net/jy692405180/article/details/52077979
http://www.cnblogs.com/CoolJie/archive/2012/07/17/graphviz.html
https://blog.csdn.net/sd10086/article/details/52979462/
https://blog.csdn.net/RobertChenGuangzhi/article/details/51593567
https://blog.csdn.net/cclethe/article/details/78745598

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值