How to use drawing layers (overlays)

 If the layers graph attribute is set, the graph is printed in a sequence of colored layers, or overlays. (This coloring overrides any other settings.) layers defines a list of layer names, each separated by a sequence of separator characters. The tokens can be any identifier or natural number, except the reserved word all. By default, the separator characters are colon, space and tab, though this can be overridden using the layersep graph attribute.

The layer attribute of a node, edge or cluster enables its appearance in given layers. Its value denotes a list of layers from the layers graph attribute. It is specified by a list of layer intervals, separated by a sequence of characters from the layerlistsep attribute. Each layer interval is written as a single layer name or two layer names separated by a sequence of separator characters from the layersep attribute. The keyword all means all possible layers. If all is used as part of a range, the range denotes all layers bounded on one side by the other token. Thus, the layer pvt:all of the edge node2 -> node3 in the example below corresponds to the layers pvt, test, new, and ofc. The  all:pvt,new,ofc corresponds to the layers local, pvt, new, and ofc.

As an example, the graph:

digraph G {

	node1  [layer="pvt"];
	node2  [layer="all"];
	node3  [layer="pvt:ofc"];		/* pvt, test, new, and ofc */
	node2 -> node3  [layer="pvt:all"];	/* same as pvt:ofc */
	node2 -> node4 [layer=3];		/* same as test */

produces the 5 layers shown below:

Layer 1
Layer 2
Layer 3

Layer 4
Layer 5

In a layered graph, if a given node (or edge) does not have a layer assignment, but incident edges (nodes, resp.) do, its layer specification is inferred from these. For example, in the examples above, node4 only appears on layer 3, because a layer assignment was given for its connecting edge. Note, however, that if a node or edge without a layer attribute is incident with an edge or node without a layer attribute (or such a node has no edges), then the node or edge appears on all layers.

To change the default so that nodes and edges with no layer attribute appear on all layers, insert

	node [layer=all];
	edge [layer=all];

at the beginning of the graph file.

The graph can have a layerselect attribute, which specifies which layers should be emitted. The value uses the same concrete syntax as the layer attribute.

At present, the output of multiple layers into a single output file is only available in PostScript. However, the layerselect attribute can be used to select a single layer for output in any format.

The color sequence for layers is set in the array layercolorseq (in Postscript at least). The first index is 1 and each element is a three-element color coordinate array. Custom layer colors can be created by setting the value of this array.



  • simply change default colors per layer, thus allowing user override on individual nodes or edges when desired.
  • turn off layer coloring entirely and just use the colors inherent in the drawing.
  • forcing nodes/edges in a given subgraph to take certain attributes. Might require a hook in the libgraph parser. It would be pretty easy to support the semantics: for every node/edge in this subgraph, assign it the default attributes that differ from the defaults of the parent of this graph. What you need to avoid is the problem exposed in the following example:
    			subgraph sub0 {
    				node [color=red];
    				a; b; c;
    			subgraph sub1 {
    				node [shape=diamond];
    				a; b; c;
    We don't want to reset a,b,c to color=black just because that is default in sub1. Solution: none, hope for a fix in libgraph.


colors in layers


I would very interested when you're going to be implementing : "turn off layer coloring entirely and just use the colors inherent in the drawing."




colors in layers


Do you know when you are likely to have implemented "turn off layer coloring entirely and just use the colors inherent in the drawing." ?

It would be wonderful !!



Recent comments