Horizontal Legend Creation

Hi ,
I want to draw a legend horizontally to the top of a graph produced by graphviz.

I have written this code
diagraph_obj.attr(‘graph’, labelloc=“t”, label=’’’<

        <TABLE BORDER="0"  CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"  VALIGN="TOP" HEIGHT="2.0">
         <TR>
          <TD COLSPAN="2"><B>Device Gen Info</B></TD>
         </TR>
         <TR>
          <TD> <FONT POINT-SIZE="10.0">Gen5</FONT> </TD>
          <TD BGCOLOR="ORANGE">  </TD>
         </TR>
         <TR>
          <TD>Gen4</TD>
          <TD BGCOLOR="GREEN"></TD>
         </TR>
         <TR>
          <TD>Gen3</TD>
          <TD BGCOLOR="YELLOW"></TD>
         </TR>
         <TR>
          <TD>Gen2</TD>
          <TD BGCOLOR="BROWN"></TD>
         </TR>
         <TR>
          <TD>Default</TD>
          <TD BGCOLOR="VIOLET"></TD>
         </TR>
         <TR>
          <TD>Timed Out</TD>
          <TD BGCOLOR="RED"></TD>
         </TR>
         <TR>
          <TD>Access Point</TD>
          <TD>Triangle</TD>
         </TR>
         <TR>
          <TD>Relay</TD>
          <TD>Parallelogram</TD>
         </TR>
          <TR>
          <TD>Bridge</TD>
          <TD>Daimond</TD>
         </TR>
          <TR>
          <TD>High Priority Access Point</TD>
          <TD>DoubleCircle</TD>
         </TR>
          <TR>
          <TD>High Priority End Point</TD>
          <TD>Trippleoctagon</TD>
         </TR>
          <TR>
          <TD>High Priority Relay</TD>
          <TD>House</TD>
         </TR>
          <TR>
          <TD>NIC</TD>
          <TD>Pentagon</TD>
         </TR>
          <TR>
          <TD>LCS</TD>
          <TD>Trapezium</TD>
         </TR>
          <TR>
          <TD>STL</TD>
          <TD>Star</TD>
         </TR>
          <TR>
          <TD>IOTR</TD>
          <TD>Circle</TD>
         </TR>
          <TR>
          <TD>Default</TD>
          <TD>Rectangle</TD>
         </TR>
          <TR>
          <TD>Timed Out</TD>
          <TD>Septagon</TD>
         </TR>
        </TABLE>
         >''')

And the legend drawn from the code snippet is vertical but I want to draw it horizontally with automatic fixed legend size.

Any help or guidance is highly appreciated.
Thanks!

Is this what you are after? (I’m not sure what “automatic fixed legend size” means)

digraph LL {
  graph [labelloc=t, label=<
        <TABLE BORDER="0"  CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"  VALIGN="TOP" HEIGHT="2.0">
         <TR>
          <TD COLSPAN="99"><B>Device Gen Info</B></TD>
         </TR>

         <TR>
          <TD> <FONT POINT-SIZE="10.0">Gen5</FONT> </TD>
          <TD>Gen4</TD>
          <TD>Gen3</TD>
          <TD>Gen2</TD>
          <TD>Default</TD>
          <TD>Timed Out</TD>
          <TD>Access Point</TD>
          <TD>Relay</TD>
          <TD>Bridge</TD>
          <TD>High Priority Access Point</TD>
          <TD>High Priority End Point</TD>
          <TD>High Priority Relay</TD>
          <TD>NIC</TD>
          <TD>LCS</TD>	  
          <TD>STL</TD>
          <TD>IOTR</TD>
          <TD>Default</TD>
          <TD>Timed Out</TD>

         </TR>
         <TR>
          <TD BGCOLOR="ORANGE">  </TD>
          <TD BGCOLOR="GREEN"></TD>
          <TD BGCOLOR="YELLOW"></TD>
          <TD BGCOLOR="BROWN"></TD>
          <TD BGCOLOR="VIOLET"></TD>
          <TD BGCOLOR="RED"></TD>
          <TD>Triangle</TD>
          <TD>Parallelogram</TD>
          <TD>Diamond</TD>
          <TD>DoubleCircle</TD>
          <TD>Trippleoctagon</TD>
          <TD>House</TD>
          <TD>Pentagon</TD>
          <TD>Trapezium</TD>
          <TD>Star</TD>
          <TD>Circle</TD>
          <TD>Rectangle</TD>


          <TD>Septagon</TD>
         </TR>
        </TABLE>>]

  // add a cluster to create margin between legend & actual graph
  subgraph clusterAll{
    graph[label="" peripheries=0]  // do not duplicate graph legend
    a ->b ->c
  }
}

Giving:

p.s. more on Legends: Adding key or legend?
p.p.s. You can replace your textual descriptions (e.g. House) with images
<TD><IMG SCALE="TRUE" SRC="image_dir/noLeft.png"/></TD>