Graphviz Issue Tracker - graphviz
View Issue Details
0002141graphvizDotpublic2011-09-28 12:212011-09-28 14:17
0002141: Triangle dimensions incorrect

I'm reporting the situation just for triangles, but on the forum thread: [^]

erg says:

"This is a bug in the shape-handling code that occurs when the [shape is] bilaterally symmetric both horizontally and vertically. In particular, it occurs if the node has an odd number of sides."

In particular when dot lays out a triangle

digraph temp {
    graph [rankdir=TB];
    node [label="\N"];
    node1 [label=" ", shape=triangle, style=filled, fillcolor="0.75 0.8 1.0", color="0.0 0.0 0.0"];

using the command

dot -Tdot -o

it claims the dimensions are:

width="0.75", height="0.68889"

which is a width/height ratio of roughly 1.09.

digraph temp {
    graph [rankdir=TB];
    node [label="\N"];
    graph [bb="0,0,54,50"];
    node1 [label=" ", shape=triangle, style=filled, fillcolor="0.75 0.8 1.0", color="0.0 0.0 0.0", pos="27,25", width="0.75", height="0.68889"];

When we ask dot to draw this triangle

dot -Tpng -o output.png

We see a triangle (output.png) that is 74 x 51, i.e. has a
width to height ratio of roughly 1.45.

How are we to interpret dot's width and height measurements so that
when we draw by dot's numbers, our shapes coincide? This is particularly
crucial when we draw edges from triangles.

No tags attached.
png output.png (1,875) 2011-09-28 12:21
Issue History
2011-09-28 12:21ianamasonNew Issue
2011-09-28 12:21ianamasonFile Added: output.png
2011-09-28 12:51ellsonNote Added: 0000073
2011-09-28 12:52ellsonNote Added: 0000074
2011-09-28 13:25ianamasonNote Added: 0000075
2011-09-28 13:59ellsonNote Added: 0000076
2011-09-28 14:17ianamasonNote Added: 0000077

2011-09-28 12:51   
The width/height is actually that of the ellipse that touches all points of the polygon. This is always produces a box that is big enough for the polygon, but not always the smallest possible. The center of the box is also the center of the largest rectangular area in the node (the label area). The geometric center is not always in the same place. It is better to keep label centers aligned across a rank of nodes, rather than the geometric centers of the node shapes.

We could produce a more accurate bounding rectangle, but we'd need to represent it with 4 coords instead of the 2 now (width, height) to allow for the offset of the center. Certainly this information is available internally.

The meaning of width, height in the dot format is really just an input constraint. As an input constraint, the output values of width, height work fine for a downstream subsequent re-layout.
2011-09-28 12:52   
BTW. A triangle is not "symmetric vertically"
2011-09-28 13:25   
Hmmmm. We use dot to layout large biological pathways, then render them in Java. See for example Currently we restrict our nodes to be ellipses and rectangles, but as things become more complex it would be nice to have a wider repetoire, like for example triangles. However to do this we would
need to be able to interpret the height and width dimensions that dot reports,
and any other information that may be relevant.
2011-09-28 13:59   
Others have used the -Txdot format which provides all the shape and spline coordinates, or perhaps you could use -Tsvg ?
2011-09-28 14:17   
Yes -Txdot does look promising. Thanks for the pointer. Very much appreciated.