"Color Scalar Bar" reworked and upgraded, now it’s called "Color Legend"

Starting from version 30530 build 2022-01-15 “Color Scalar Bar” section from “Colors” module was replaced with “Color Legend” section.

The “Color Legend” section has been also added to the “Volume”, “Model” and “Markups” modules to control visibility and behavior of color legend.

New major features:

  1. More unified API. Each Volume, Model, Markups or any other displayable node now can have an individual color legend by means of vtkMRMLColorLegendDisplayNode.

  2. Displayed LUT is in sync with range of displayed values of primary display node;

  3. Resizable title of color legend;

  4. Control of visibility of color legend on each slice or 3D view.

  5. Color legend can by added to any displayable node (if the node has a primary display node) by means of Color module logic and AddDefaultColorLegendDisplayNode method.

  6. The access to a low level vtkScalarBarActor for developers and experienced users is described here.

There are still some features that must be added. Issue to check the progress is here.

Any other required or recommended features can added to the issue or in this topic.


@Mik Thank you very much! This feature was missing for a very long time and it will make an impact in many projects.

Hi Mik

Thank you for your development about color scalar bar

I try to plot the scalar bar on “View1” (i.e., 3D view).
“View1” was selected in the View panel, but the color bar is not displayed in the 3D view as shown in the example above.

Is there a way to solve this problem ?


For what data are you trying to display color legend in 3D: scalar volume, model or something else? Currently there is a limitation of showing color legends in 3D.

It is scalar volume.

I made a volume rendering plot using scientific data (as colormap)
And I would like to make color legend of this volume rendering

As far as I search, the color legend in 3D look likt only for model. Is it right?

Correct. Color legend can be shown in 3D for models.

@Mik submitted a pull request that will allow displaying color legend of volumes shown slice views to be shown in 3D views as well. It’ll be available in the Slicer Preview Release within a few days.

If you enable “Synchronize with Volumes module” in Volume rendering module’s Advanced / Volume Properties section then the same color legend applies to volume rendering and slice views. However, if you use any other volume rendering preset then there is no GUI for making the volume rendering’s Scalar Color Mapping appear as a color legend, but you can achieve it by copy-pasting this Python script into the Python console in Slicer:

# Get colormap from first volume rendering property node
colorMapOfVolumeRendering = getNode('*Prop*').GetColor()

# Add color node
colorNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLProceduralColorNode")
colorNode.UnRegister(None)  # to prevent memory leaks
colorMap = colorNode.GetColorTransferFunction()

# Add an empty displayable node (you can only show a color legend if it belongs to a displayable node)
displayableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLModelNode", "volume")
displayNode = displayableNode.GetDisplayNode()

# Display color legend
colorLegendDisplayNode = slicer.modules.colors.logic().AddDefaultColorLegendDisplayNode(displayableNode)

@mik if you have time you might consider adding display of color legend for volume rendering (but instead of creating a separate color node, take the colormap from the volume property node). However, I’m not sure how often users want to display color legend for volume rendering.

The color legend for volume rendering should be displayed only in 3D?