Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HTML labels? #12

Closed
jyuhuan opened this issue Jun 9, 2015 · 1 comment
Closed

Support for HTML labels? #12

jyuhuan opened this issue Jun 9, 2015 · 1 comment

Comments

@jyuhuan
Copy link

jyuhuan commented Jun 9, 2015

How do I create the following graph using your library (this is from the official website of GraphViz):

digraph structs {
    node [shape=plaintext];

    struct1 [label=<<TABLE>
    <TR>
        <TD>line 1</TD>
        <TD BGCOLOR="blue"><FONT COLOR="white">line2</FONT></TD>
        <TD BGCOLOR="gray"><FONT POINT-SIZE="24.0">line3</FONT></TD>
        <TD BGCOLOR="yellow"><FONT POINT-SIZE="24.0" FACE="ambrosia">line4</FONT></TD>
        <TD>
          <TABLE CELLPADDING="0" BORDER="0" CELLSPACING="0">
          <TR>
            <TD><FONT COLOR="green">Mixed</FONT></TD>
            <TD><FONT COLOR="red">fonts</FONT></TD>
          </TR>
          </TABLE>
        </TD>
    </TR>
    </TABLE>>];
}
@xflr6
Copy link
Owner

xflr6 commented Jun 9, 2015

It translates pretty much directly (support for HTML-labels was added in #6):

from graphviz import Digraph

g = Digraph('structs', node_attr={'shape': 'plaintext'})

g.node('struct1', label='''<
<TABLE>
  <TR>
    <TD>line 1</TD>
    <TD BGCOLOR="blue"><FONT COLOR="white">line2</FONT></TD>
    <TD BGCOLOR="gray"><FONT POINT-SIZE="24.0">line3</FONT></TD>
    <TD BGCOLOR="yellow"><FONT POINT-SIZE="24.0" FACE="ambrosia">line4</FONT></TD>
    <TD>
      <TABLE CELLPADDING="0" BORDER="0" CELLSPACING="0">
        <TR>
          <TD><FONT COLOR="green">Mixed</FONT></TD>
          <TD><FONT COLOR="red">fonts</FONT></TD>
        </TR>
      </TABLE>
    </TD>
  </TR>
</TABLE>>''')

g.view()

Another more complex exampe from the Graphviz docs is in tests/test_dot.py.

@xflr6 xflr6 closed this as completed Jun 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants