Graphviz dot: How to change the colour of one record in multi-record shape

你。 提交于 2019-11-30 01:25:33

I'm pretty sure that it's not possible. Instead you should use HTML-style labels, that are a more developped form of record nodes. You can define your node using the <table> tag, and set the color using bgcolor="your_color". A list of available colors is available here: http://www.graphviz.org/doc/info/colors.html (you also have a RGBA way of doing it, as described here: http://www.graphviz.org/doc/info/attrs.html#k:color)

With HTML labels, your example becomes as follows:

digraph G
{
    rankdir = LR;
    node1
    [
        shape = none
        label = <<table border="0" cellspacing="0">
                    <tr><td port="port1" border="1" bgcolor="red">corpus_language</td></tr>
                    <tr><td port="port2" border="1">id: en</td></tr>
                    <tr><td port="port3" border="1">name: Englist</td></tr>
                    <tr><td port="port4" border="1">sentence_count: 1027686</td></tr>
                </table>>
    ]
    node2
    [
        shape = none
        label = <<table border="0" cellspacing="0">
                    <tr><td port="port1" border="1" bgcolor="blue">corpus_sentence</td></tr>
                    <tr><td port="port2" border="1">id: 1241798</td></tr>
                    <tr><td port="port3" border="1">text: Baseball is a sport</td></tr>
                    <tr><td port="port4" border="1">creator_id: 10859</td></tr>
                    <tr><td port="port5" border="1">created_on: 2006-11-14 17:58:09.303128</td></tr>
                    <tr><td port="port6" border="1">language_id: en</td></tr>
                    <tr><td port="port7" border="1">activity_id: 11</td></tr>
                    <tr><td port="port8" border="1">score: 124</td></tr>
                </table>>
    ]
    node1:port2 -> node2:port6 [label="language_id"]
}

Here is the result:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!