Using the Color Map Editor in ParaView – The Categorical Colors

November 24, 2013

In the previous posts ([1], [2]), we covered several aspects on using the Color Map Editor panel in ParaView introduced in version 4.1. In this final installment in the series, we take a look at categorical colors and how they can be useful for certain visualization use-cases.

Overview


A picture is worth a thousand words, they say, so let’s just let the picture do the talking. Categorical color maps allow you to render visualizations as shown in Figure 1.


Figure 1: Visualization using a categorical color map for discrete coloring
When one thinks of scalar coloring, one is typically talking of mapping numerical values to colors. However, in some cases the numerical values are not really numbers, but enumerations such as elements types, or gear types (as in Figure 1), or generally speaking, categories. The traditional approach of using an interpolated color map specifying range of values to color with doesn’t really work here. While users could always play tricks with number of discrete steps, multiple control points, and annotations, it is tedious and cumbersome.

Categorical color maps, introduced in 4.0.1, provide an elegant solution for such cases. Instead of a continuous color transfer function, user specifies a set of discrete values and colors to use for those values. For any element where the data value exactly matches the values in the lookup table, ParaView renders the specified color, otherwise the NaN color is used.

The color legend or scalar bar also switches to a new mode where it renders swatches with annotations, rather than a single bar. Users can add custom annotations for each value in the lookup table.

The User Interface


To tell ParaView that the data array is to be treated as categories for coloring check the Interpret Values As Categories checkbox in the Color Map Editor panel. As soon that’s checked, the panel switches to categorical mode: the Mapping Data group is hidden and Annotations group becomes a non-advanced group i.e. the annotations widget is visible even if the panel is not showing advanced properties, as shown in Figure 2.


Figure 2: Default Color Map Editor when Interpret Values As Categories is checked
The annotations widget will still show any annotations that may have been added earlier, or be empty if none were added. One can add annotations for data values as before using the buttons on the side of the widget. This time, however, each annotation entry also has a column for color. If no color has been specified, a question mark icon will show up, otherwise a color swatch will be shown. One can double click the color swatch or the question mark icon to specify the color to use for that entry. Alternatively, one can choose from a preset collection of categorical color maps by clicking the Choose preset button.


Figure 3: Choose preset dialog for categorical color maps
As before, one can use Tab key to edit and add multiple values. Hence, one can first add all the values of interest in one pass and then pick a preset color map to set colors for the values added. If preset has fewer colors that the annotated values, then user may have to manually set the colors for those extra annotations.

Also Add active values plays the same role as described in previous post: fill the annotations widget with unique discrete values from the data array, is possible. Based on the number of distinct values present in the data array, this may not yield any result (instead a warning message will be shown).

To see how to use categorical colors for coloring contours, check out my previous blog post.

Caveats


Categorical color maps are designed for data arrays with enumerations which are typically integer arrays. However they can be used for arrays with floating point number as well. However with floating point numbers, the value specified for annotation may not exactly match the value in the dataset even when the user expected it to match. In that case, the NaN color will be used. In future, we may add a mechanism to specify a delta to use to when comparing data values to annotated values.

Wrap-Up


That is pretty much it! And as always, if you have any suggestions, feel free to use the mailing lists or user-voice to bring them up.

3 comments to Using the Color Map Editor in ParaView – The Categorical Colors

  1. Hi Utkarsh

    I have read your post about color mapping categorical data. Is there a way to label selected cells or points using categorical strings rather than integers(given the string-integer dictionary already exists)?

    Many thanks
    Wei

  2. I noticed this old post. I guess there was not much progress on adding the possibility of labeling float data in a certain range?

Leave a Reply