How to apply preset color map to vtkColorTransferFunction?


I need to color a PolyData points/cells by a value in its fields.

This works well, but how can I use a preset color maps (e.g. “Cool to Warm”) for coloring?
In vtk.js one can do

      const preset = vtkColorMaps.getPresetByName("Cool to Warm");

How can I do the same with VTK? I see the presets exist in vtkm’s ColorTable.h, but there’s no ApplyColorMap to use it in vtkColorTransferFunction. Do the value points need to be copied by hand, or is there a shortcut method to use the ColorTable?

Thanks in advance!

Hi, Eino,

As far as I know, that is a higher level functionality added to vtk.js. I don’t think the VTK base library has something like this and you probably have to write code to make a preset collection of color tables like this user here: Display data with a "preset" LookupTable . Maybe you can copy the part of Paraview code (GitHub - Kitware/ParaView: VTK-based Data Analysis and Visualization Application) that implements it.



1 Like

My comments here may be useful: Thermograph color map

1 Like

Thank you for your answers. Indeed seems I will need to implement it by hand