LinuxCommandLibrary

gvcolor

Color directed graphs based on node attributes

TLDR

Colorize one or more ranked digraph (that were already processed by dot)

$ gvcolor [path/to/layout1.gv path/to/layout2.gv ...] > [path/to/output.gv]
copy

Lay out a graph and colorize it, then convert to a PNG image
$ dot [path/to/input.gv] | gvcolor | dot -T [png] > [path/to/output.png]
copy

Display help
$ gvcolor -?
copy

SYNOPSIS

gvcolor [-?] [-V] [-G<attr>] [-N<attr>] [-E<attr>] [-f<file>] [-n<v>] [-c<v>] [-e<v>] [-s<v>] [file]

PARAMETERS

-?
    Displays usage information and exits.

-V
    Prints the version information of gvcolor and exits.

-G<attr>
    Specifies the graph attribute to check for group ID. Defaults to group.

-N<attr>
    Specifies the node attribute to check for group ID. Defaults to group.

-E<attr>
    Specifies the edge attribute to check for group ID. Defaults to group.

-f<file>
    Provides a file containing a custom color scheme to be used.

-n<v>
    Sets the maximum number of colors to use from the default palette. Default is 11; maximum allowed is 11.

-c<v>
    Selects the base ColorBrewer palette by ID (0-23). Default is 0.

-e<v>
    Specifies the number of additional ColorBrewer palettes to append to the base scheme. Default is 0.

-s<v>
    Sets the saturation level for generated colors, ranging from 0.0 (grayscale) to 1.0 (full saturation). Default is 0.5.

file
    The input graph file in DOT format. If omitted, gvcolor reads from standard input.

DESCRIPTION

gvcolor is a specialized utility included in the Graphviz package, designed to enhance the visual clarity of graph diagrams. Its primary function is to assign colors to nodes and edges within a graph, based on a specified numeric attribute, typically group.

The command reads a graph in the DOT language format from standard input or a specified file. For each node or edge, gvcolor inspects the value of the designated attribute (defaulting to group). If this attribute contains a numeric value, it maps this value to a distinct color from a predefined palette or a user-supplied color scheme. This automatic coloring is invaluable for visually distinguishing related components or highlighting specific clusters within complex graphs.

The output is another DOT file, with the added color attributes for the modified nodes and edges. This colored DOT file can then be rendered into various image formats (like PNG, SVG, PDF) using Graphviz layout engines such as dot, neato, or fdp. It is commonly used in pipelines, for example, unflatten | gvcolor | dot -Tpng > graph.png, to automatically generate aesthetically pleasing and informative graph visualizations.

CAVEATS

gvcolor primarily relies on numeric values in the specified group or custom attributes for coloring. Non-numeric values will be ignored for coloring purposes.

The default color palette is limited to 11 distinct colors. For more variation, custom color scheme files or ColorBrewer options must be utilized.

It is part of the Graphviz suite and not a standalone general-purpose text processing tool. It expects DOT format input and produces DOT format output.

COLOR SCHEMES AND PALETTES

gvcolor supports using various color schemes. The -c (base palette ID) and -e (additional palettes) options allow users to leverage ColorBrewer palettes, which are designed for optimal readability and perceptual uniformity. This provides a wide range of well-suited color sets for different types of data visualization.

INPUT AND OUTPUT FORMAT

gvcolor exclusively processes graph descriptions in the DOT language. It reads DOT format from an input file or standard input and outputs a modified DOT file to standard output, with color attributes added to relevant nodes and edges.

HISTORY

gvcolor is an integral component of the open-source Graphviz project, which was initially developed at AT&T Labs Research. Graphviz, including tools like gvcolor, has evolved significantly since its inception to become a widely used suite for visualizing structural information, particularly graphs and networks. Its development has focused on providing automated and aesthetically pleasing ways to represent complex data relationships. gvcolor's specific role in this evolution has been to provide an accessible and automated method for distinguishing graph elements by groups, greatly enhancing the interpretability of large or intricate visualizations.

SEE ALSO

dot(1): Graphviz layout engine, neato(1): Graphviz layout engine, twopi(1): Graphviz layout engine, circo(1): Graphviz layout engine, fdp(1): Graphviz layout engine, sfdp(1): Graphviz layout engine, gvpr(1): Graphviz graph processing language, unflatten(1): Graphviz tool to remove flat edges

Copied to clipboard