# VTK Examples - Some ColorMap to LookupTable tools

**URL:** https://discourse.vtk.org/t/vtk-examples-some-colormap-to-lookuptable-tools/12237
**Category:** Announcements
**Created:** [September 4, 2023, 1:17am UTC](https://discourse.vtk.org/t/vtk-examples-some-colormap-to-lookuptable-tools/12237 "2023-09-04T01:17:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [September 4, 2023, 1:17am UTC](https://discourse.vtk.org/t/vtk-examples-some-colormap-to-lookuptable-tools/12237/1 "2023-09-04T01:17:28Z")

</div>

## Introduction

There is nothing in VTK that allows you to easily import colormaps. So it is hoped that these examples address this and make it easier for users to import or create their own colormaps.

Hopefully this will make VTK a more colorful and happier place!

## The Programs

These two Python programs will allow you to generate and visualise XML or JSON colormaps on a cone (a sphere is also provided - commented out). They also have the ability to generate a C++ or Python function that you can automatically incorporate into your code.

- [ColorMapToLUT\_XML](https://examples.vtk.org/site/Python/Utilities/ColorMapToLUT_XML/)

- [ColorMapToLUT\_JSON](https://examples.vtk.org/site/Python/Utilities/ColorMapToLUT_JSON/)

## Examples

These two examples demonstrate how to do this using the autogenerated function from either of the above programs:

- [ColorMapToLUT.cxx](https://examples.vtk.org/site/Cxx/Utilities/ColorMapToLUT/)

- [ColorMapToLUT.py](https://examples.vtk.org/site/Python/Utilities/ColorMapToLUT/)

## Comments

These tools were inspired by this discussion: [Replacement default color map and background palette](https://discourse.paraview.org/t/replacement-default-color-map-and-background-palette/12712). I have used the **Fast** colormap from this discussion.

A good initial source for color maps is: [SciVisColor](https://sciviscolor.org/) - this will provide you with plenty of XML examples.

See also:

- [How to export ParaView colormap into a format that could be read by matplotlib](https://discourse.paraview.org/t/how-to-export-paraview-colormap-into-a-format-that-could-be-read-by-matplotlib/2436)

- [How to export ParaView colormap into a format that could be read by matplotlib?](https://discourse.paraview.org/t/how-to-export-paraview-colormap-into-a-format-that-could-be-read-by-matplotlib/2394)

- [Color map advice and resources](https://discourse.paraview.org/t/color-map-advice-and-resources/6452/4)

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [September 5, 2023, 12:49pm UTC](https://discourse.vtk.org/t/vtk-examples-some-colormap-to-lookuptable-tools/12237/2 "2023-09-05T12:49:18Z")

</div>

I’m really glad to see better colormap support - it’s an underappreciated aspect of good visualization practices. Thanks Andrew!

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [November 30, 2023, 4:08am UTC](https://discourse.vtk.org/t/vtk-examples-some-colormap-to-lookuptable-tools/12237/3 "2023-11-30T04:08:05Z")

</div>

I have updated [ColorMapToLUT\_JSON](https://examples.vtk.org/site/Python/Utilities/ColorMapToLUT_JSON/) to support choosing a colormap by name e.g. from [ParaView Default Colormaps](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Remoting/Views/ColorMaps.json). In this case you can look at the colormaps in ParaView and select the the one you want from the from the ParaView JSON file.

Two new programs have been added:

- [RescaleReverseLUT.py](https://examples.vtk.org/site/Python/Utilities/RescaleReverseLUT/)
- [RescaleReverseLUT.cpp](https://examples.vtk.org/site/Cxx/Utilities/RescaleReverseLUT/)

These allow you to adjust a colormap so that the colormap scalar range matches the scalar range of the object by rescaling the control points and, optionally, reversing the order of the colors.
