New in ParaView: Coloring by string arrays

ParaView has always been able to map numerical values associated with points and cells to colors. ParaView 4.3 has the ability to map string arrays to colors. This feature works for string arrays in point data, cell data, and field data using the new feature that enables you to color by the first tuple in a field data array.

Coloring by string arrays is possible when the color map option “Interpret Values As Categories” is enabled and a set of annotations whose values are strings in the data array is defined. As with other cases where values are interpretted as categories, a set of active values can be obtained automatically from the data and defined as annotations using the tools in the Color Map Editor’s Annotations section.

Let’s take a look at an example data set that contains the countries of the world. The cells in the file that defined the countries have an associated string array named “REGION” that encodes the region in which the country is located. The image below shows the results of coloring by this region string array. Labels in the color legend show the region string values in the map data set.

The data file and ParaView state file that produced this image is attached to this post. You can try it out with ParaView 4.3 Release Candidate 1, available at the ParaView downloads page.

Mapping string arrays to colors in VTK

Coloring by string arrays is implemented in VTK, so any VTK-based application can do it. For example, imagine you have a data set where the colors to be used for cell data are defined by strings naming the colors. You can set up a vtkLookupTable  to map these strings to the actual colors using the following code:

Happy color mapping!

4 Responses to New in ParaView: Coloring by string arrays

  1. Pingback: wei

  2. Pingback: Cory Quammen

    • Pingback: Maria Torres

      • Pingback: Cory Quammen

Questions or comments are always welcome!