Graphviz:如何减小节点的顶部和底部边距?

11

我该如何减少Graphviz节点的上下边距? 我为每个节点指定了“0.05,0.0”作为边距,字体大小为8。

2个回答

16
digraph { rankdir = LR
    node [shape=box margin=0 width=0 height=0]
    asdf [label="asdf\nasdf"]
    qwer [label="qwerqwer"]
    asdf -> qwer
}

3
请为x和y指定边距 margin="0.1,0.5",详情请参见 https://www.graphviz.org/doc/info/attrs.html#d:margin。 - stefan
@Alex 请看上面的注释。 - stefan
奇怪的是,这对我不起作用(设置“0,0”)。 - Alex Lenail

4
节点有默认的最小尺寸(宽度和高度),因此如果你将边距缩小到一定程度,它将不起作用。至少对于方形节点和其他一些简单形状是这样工作的。
实际上,widthheight 指定的是最小宽度和高度,而不是实际的宽度和高度(除非你还指定了大小是固定的)。因此,为了获得更小的边距,你可以使用非常小的widthheight 值,形状仍然会被拉伸以适应标签。
带默认值:
digraph {
    node [shape=box]
    a -> "longer name"
    "longer name" -> "taller\nname"
}

enter image description here

更小:

digraph {
    node [shape=box,width=0.1,height=0.1]
    a -> "longer name"
    "longer name" -> "taller\nname"
}

enter image description here

你也可以设置边距本身,如果你想要它更小:

digraph {
    node [shape=box,width=0.1,height=0.1,margin=0.01]
    a -> "longer name"
    "longer name" -> "taller\nname"
}

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接