英文:
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?
英文:
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?
答案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
}
}
不幸的是,图形的外边缘仍然保留着一个较细的边框,这不受上述两个边距规范的控制。
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论