# SVG is huge no matter the actual graph size

**URL:** <https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742>\
**Category:** Help\
**Created:** [July 12, 2021, 12:55am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742 "2021-07-12T00:55:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronman](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronman](https://forum.graphviz.org/u/ronman)\
**Post date:** [July 12, 2021, 12:55am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/1 "2021-07-12T00:55:09Z")

</div>

Why is my svg output huge even for very small graphs (4 nodes)?

Adding bb, size, or viewport arguments has no effect.

Similarly using layout engines dot or circo.

Here’s the svg header for a 4 node graph laid out by dot:

```auto
<svg width="1375pt" height="1422pt"
 viewBox="1152.00 1152.00 1578.00 1692.00" .... etc.

```

I can constrain it somewhat when displaying the svg in a web page by using width= and height= arguments on the object or img tag that I use to display the svg, but that’s a hack, and the margin around the graph is still too large.

I’m using graphviz 2.47

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 12, 2021, 1:06am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/2 "2021-07-12T01:06:03Z")

</div>

Can you share the graph?

---

<div class="post-metadata">

**Author:** ![ronman](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronman](https://forum.graphviz.org/u/ronman)\
**Post date:** [July 12, 2021, 2:53am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/3 "2021-07-12T02:53:18Z")

</div>

```auto
digraph mygraph {
graph [mindist="3.0" notranslate="true" margin="16.0" pad="16.0" labelloc=t size="2.5,1.5" inputscale="72" compound="true" fontname="NimbusSans-Bold" concentrate="false" nodesep="0.50" sep="+16.0" esep="+12.0" ranksep="1.0" maxiter="500" overlap="prism" truecolor="false" dpi="72" splines="spline" rankdir="TB"]
node [pin="true" margin="32.0" fixedsize="true" fontsize="100.0" fontname="NimbusSans-Bold"]
edge [weight="300" len="0.25" arrowsize="4.0" arrowhead="normal" fontsize="42.0" labeldistance="1.5" tailclip="true" headclip="true" color="#000000" penwidth="1.0" fontname="NimbusSans-Bold"]
"36510" [ID="36510" pos="162.0,846.0" width="2.50" height="2.50" shape="rectangle" style="filled,rounded" fontcolor="#000000" fillcolor="#f0e68cff" pencolor="#000000" label="d"]
"36507" [ID="36507" pos="90.0,594.0" width="2.50" height="2.50" shape="rectangle" style="filled,rounded" fontcolor="#000000" fillcolor="#f0e68cff" pencolor="#000000" label="a"]
"36509" [ID="36509" pos="90.0,342.0" width="2.50" height="2.50" shape="rectangle" style="filled,rounded" fontcolor="#000000" fillcolor="#f0e68cff" pencolor="#000000" label="c"]
"36508" [ID="36508" pos="162.0,90.0" width="2.50" height="2.50" shape="rectangle" style="filled,rounded" fontcolor="#000000" fillcolor="#f0e68cff" pencolor="#000000" label="b"]
"36507" -> "36509" [origin="36507" target="36509" ID="65556" weight="0" style="solid" color="#000000ff"]
"36509" -> "36508" [origin="36509" target="36508" ID="65557" weight="0" style="solid" color="#000000ff"]
"36508" -> "36510" [origin="36508" target="36510" ID="65558" weight="0" style="solid" color="#000000ff"]
"36510" -> "36507" [origin="36510" target="36507" ID="65559" weight="0" style="solid" color="#000000ff"]
}

```

I also just tried removing the pos= arguments; made no difference to the dimensions of the svg.

---

<div class="post-metadata">

**Author:** ![schmoo2k](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/schmoo2k/32/29_2.png) [@schmoo2k](https://forum.graphviz.org/u/schmoo2k)\
**Post date:** [July 12, 2021, 6:24am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/4 "2021-07-12T06:24:10Z")

</div>

FYI Margin is in inches so your defaulting your Node margin to 32.0 inches! and then your setting the font size to 100 (normally would be 11 or 12).

I would suggest removing all you “custom” sizes and add them back one at a time now you know their in inches!!!

Playground here: [Untitled / Gordon Smith / Observable (observablehq.com)](https://observablehq.com/@gordonsmith/untitled/3)

---

<div class="post-metadata">

**Author:** ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)\
**Post date:** [July 13, 2021, 1:24am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/5 "2021-07-13T01:24:21Z")

</div>

I don’t see any harm in our someday adding dimensions to input units (e.g. 2.0i, 100px, 18pt, etc.) as this could be done in way that is completely backward compatible and it might be constructive.

---

<div class="post-metadata">

**Author:** ![ronman](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@ronman](https://forum.graphviz.org/u/ronman)\
**Post date:** [July 13, 2021, 2:04am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/6 "2021-07-13T02:04:04Z")

</div>

@schmoo2k That solved it, and the observable link saves a lot of time.

@scnorth That would be **very** welcome to have. As a result of this error, I’m making a note to self to be more diligent about commenting code that generates dot source as to what units values are in, but your solution would be self-documenting.

Also, some units (mindist) have to be deduced by their default values, since the doc doesn’t explicitly say what the units are.

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/mark/32/84_2.png) [@mark](https://forum.graphviz.org/u/mark)\
**Post date:** [July 14, 2021, 9:28am UTC](https://forum.graphviz.org/t/svg-is-huge-no-matter-the-actual-graph-size/742/7 "2021-07-14T09:28:29Z")

</div>

Good idea. Filed feature request  
[https://gitlab.com/graphviz/graphviz/-/issues/2100](https://gitlab.com/graphviz/graphviz/-/issues/2100) to track
