使用Graphviz的`dot`命令生成无边框图像。

huangapple go评论100阅读模式
英文:

Produce borderless image with the `dot` command of graphviz

问题

Currently when I produce an image with graphviz, I get a border which is pretty hard to auto-remove without rasterizing the PDF:

echo 'digraph { a -> b }' | dot -Tpdf > output.pdf

Produces the following graphic, in which I have highlighted the borders in red.
These are areas which appear white on the original result but contain no meaningful information.

Is there any way to prevent dot from producing these borders instead of relying on additional packages to fix the issue downstream?

使用Graphviz的`dot`命令生成无边框图像。

英文:

Currently when I produce an image with graphviz, I get a border which is pretty hard to auto-remove without rasterizing the PDF:

echo 'digraph { a -> b }' | dot -Tpdf > output.pdf

Produces the following graphic, in which I have highlighted the borders in red.
These are areas which appear white on the original result but contain no meaningful information.

Is there any way to prevent dot from producing these borders instead of relying on additional packages to fix the issue downstream?

使用Graphviz的`dot`命令生成无边框图像。

答案1

得分: 1

margin(https://graphviz.org/docs/attrs/margin/)似乎是引起问题的原因。对于许多输出格式,默认情况下是一个较小的边距,但对于pdf,默认情况下是较大的边距。

digraph {
graph [margin=0]
a -> b
}

然而,这也会移除任何子图周围的边框。如果只想移除外部图形边框,请使用:

digraph {
graph [margin=0]
a -> b
subgraph cluster0 {
   margin = 10;
   b -> c
   }
}

不幸的是,图形的外边缘仍然保留着一个较细的边框,这不受上述两个边距规范的控制。

使用Graphviz的`dot`命令生成无边框图像。

英文:

margin (https://graphviz.org/docs/attrs/margin/) seems to be causing the problem. For many output formats, a small number is the default, for pdf, a larger margin is the default.

digraph {
graph [margin=0]
a -> b
}

This, however, will also remove the borders around any subgraphs. If you only want to remove the outer graph border, use:

digraph {
graph [margin=0]
a -> b
subgraph cluster0 {
   margin = 10;
   b -> c
   }
}

Sadly, though, there remains a thinner border around the outer edge of the figure, which is not controlled by either of the 2 margin specifications given above:

使用Graphviz的`dot`命令生成无边框图像。

huangapple
  • 本文由 发表于 2023年6月12日 10:52:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76453384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定