Satnam
Satnam

Reputation: 23

Graphviz node split

Okey so how to split node in graphviz in the middle to divide node in two parts with different colors and how to write text in multi line columns.

I know Graph viz is HTML based, but I can't make any workaround I need some examples.

I want to get something like this:

|------|
|Title |<-- red background
|------|
|text1 |
|text2 |<- green background
|______|

My example code looks like:

digraph G {
  node [shape=box] <- don't know how to make it divided Up/Down parts
  node1 {label = "Title"}
  node2 [label = "text1\\text2"]  <- Don't know what to do here 

  node1 -> node1 ;
  node1 -> node2 ;
}

Thanks in advance.

Upvotes: 1

Views: 1623

Answers (1)

stefan
stefan

Reputation: 3759

Most likely you want to use HTML-like-labels

digraph structs {
    node [shape=plaintext]
    struct [label=<
        <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
            <TR><TD PORT="title" bgcolor="red">Title</TD></TR>
            <TR><TD PORT="text" bgcolor="green">text1<br />text2</TD></TR>
        </TABLE>>];
    // example edge
    struct:title:w -> struct:text:s
}

enter image description here

Upvotes: 3

Related Questions