Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two colours in one node with graphviz's dot?

Tags:

graphviz

dot

I'm wondering if it is possible to split a node into two different colours. I'm using graphviz's dot (http://www.graphviz.org/).

Perhaps a verticle, or diagonal line could split the node into two colours. I want to do this because I have many nodes which belong to two different categories (colours) with some nodes belonging to both.

Many thanks, James

like image 508
James Avatar asked Jan 26 '12 20:01

James


3 Answers

Gradient functionality was only added to Graphviz on January 26, 2012; until the new 2.30.0 stable version of Graphviz is released, you'll need to download Graphviz development version 2.29.20120127.0545 or newer.

In addition, gradients seem to only be implemented for the Cairo/Pango renderer so far; in my tests, the Quartz (Mac) and GD renderers fall back to using just the first color. In particular, this means if you're on a Mac and are using the Graphviz.app GUI viewer, you won't see gradients there (yet).

digraph G {
  Gradient [style="filled", fillcolor="orange:yellow"]
}

enter image description here

like image 154
ryandesign Avatar answered Oct 31 '22 22:10

ryandesign


I don't think there is an out-of-the-box solution to have 2 background colors.

The best solution would be to use gradient fills (fillcolor="orange:yellow") - but though this is in the documentation, I wasn't able to make it work on my box.

You could use HTML-like labels as a workaround. You may need to split the label to have it centered, depending on your needs:

a[shape="none", label=<
<table cellpadding="0" cellborder="0" cellspacing="0" border="0">
<tr>
<td bgcolor="orange">abc</td>
<td bgcolor="yellow">def</td>
</tr>
</table>
>]

2 colors

like image 7
marapet Avatar answered Oct 31 '22 21:10

marapet


It is possible, if you use the image attribute of a label and provide a suitable background image:

digraph G {
  i1 [shape=none, image="range.png", label=""];
  i2 [shape=none, image="range.png", label="Image w label", imagescale=true];
  i1 -> i2;
}

This gives the following output:

enter image description here

using the range.png file

enter image description here

like image 1
dgw Avatar answered Oct 31 '22 23:10

dgw