Images in nodes, label below

Hallo, i want to diplay images in my nodes, just similar to the Kennedy family tree in the gallery.
the first lines of my code:

digraph B {
rankdir=LR
nodesep=0.7
node [shape=box, fontname=arial, fontsize=10]
edge [fontname=arial, fontsize=8]
splines=true
p1 [shape=hexagon, style=bold, label=<first line<br/><font point-size="8">second line</font>>, image="image_path\image_name.jpg", labelloc=b]
.
.

the problem is, that the label appears in the middle of the picture, and not below. But that is barely readable. how do I force that the label is displayed below the image?

best regards
uwe pintaske

Are there some actual examples around?

That demonstrate some of these techniques.  I'm having trouble following these

clues.  Does the fixedside attribute belong to the node (no joy here), or

the TD (partial joy here).   For example this:

 

digraph structs {

     struct1 [margin=0 shape=box, style=filled, fillcolor=white, color=blue, label=<<TABLE border="0" cellborder="0">
                       <TR><TD width="60" height="50" fixedsize="true"><IMG SRC="g0.png" scale="true"/></TD><td><font point-size="10">protein2ppw</font></td></TR>
              </TABLE>>];

     struct2 [margin=0 shape=box, style=filled, fillcolor=white, color=red, label=<<TABLE border="0" cellborder="0">
                       <TR><TD width="60" height="50" fixedsize="true"><IMG SRC="g0.png" scale="true"/></TD><td><font point-size="10">[email protected]</font></td></TR>
              </TABLE>>];

     struct3 [margin=0 shape=box, style=filled, fillcolor=white, color=green, label=<<TABLE border="0" cellborder="0">
                       <TR><TD width="60" height="50" fixedsize="true"><IMG SRC="g0.png" scale="true"/></TD><td><font point-size="10">[email protected]</font></td></TR>
              </TABLE>>];

    struct1 -> struct2;
    struct1 -> struct3 ;

}

 

produces the attached image,  but also  complains:

 

 dot -Tpng stable.dot -o stable.png
Warning: cell size too small for content
in label of node struct1
Warning: cell size too small for content
in label of node struct2
Warning: cell size too small for content
in label of node struct3

 

If you put the fixedsize

If you put the fixedsize attribute inside <TD>, it applies to the cell. If you make it part of a node's attribute, it applies to the node. The warning just indicates that the size of the image, plus the default 2 points of padding, is larger than the specified 60x50 points of the fixed size. Note that, in this case, the image is uniformly scaled down to fit the cell size. Hence, your nodes look good to me. If you feel there is something wrong, let us know.

There are various ways. The

There are various ways. The best is to use a TABLE HTML-like label:
 
 p1 [margin=0 shape=hexagon, style=bold, label=<<TABLE border="0" cellborder="0">
<TR><TD><IMG SRC="image_name.jpg"/></TD></TR>
<TR><TD>first line<br/><font point-size="8">second line</font></TD></TR>
</TABLE>>]
 
Another approach is to increase the minimum height, using the height attribute, to provide space. Note that the labelloc attribute is only used in nodes when the node height is more than the label height. The downside to this approach is that everything is vertically centered, so to guarantee that the label does not overlap the image, there will also be extra space at the top.
 
A third approach is the trick used by the person who created the Kennedy tree. His images contain blank space at the bottom, so even though the label is written over the image, it doesn't look that way.
 

Thank's a lot, the TABLE

Thank's a lot, the TABLE label works very well. Is it possible to limit the image-size, because all my images have different dimensions.
Why doesn't it work, to display the images correctly with output format "PDF". In the result with format "JPG" or "PNG" the images look quite normal, but in "PFD" the colors are inverted (mostly the white background)...

Specify a width and height

Specify a width and height for each TD enclosing an image, and set FIXEDSIZE="true". Then set the IMG attribute SCALE="true". This way, each cell will have a fixed size for the image, and each image will be scaled uniformly to fit.
 
I'm not seeing a problem with PDF output. Please submit a bug report with a sample input graph and image that exhibits the problem. Thanks.
http://www.graphviz.org/content/graphviz-issue-tracker

Recent comments