I wanted to visualize color bar in slice views today, and I was reminded how difficult it is to find this functionality. I think the only reason I was able to find it is because I knew it was possible to do that, I know who contributed that functionality, so I was able to search my email and find this PR: Issues with window level and threshold on the volume module, display panel · Issue #235 · Slicer/Slicer · GitHub, and then I saw and remembered that this functionality is hidden in the “Data Probe” module (not to be confused with the “DataProbe” area of the interface!).
In case someone else needs to do this (or does not know this is possible), here’s how to enable scalar bar:
File “/home/saima/Slicer-4.11.0-2020-02-25-linux-amd64/Visualisation/Visualisation/Visualisation.py”, line 115, in setParameterNode
self.updateGUIFromParameterNode()
File “/home/saima/Slicer-4.11.0-2020-02-25-linux-amd64/Visualisation/Visualisation/Visualisation.py”, line 147, in updateGUIFromParameterNode
self.scalarBar.checked = (self._parameterNode.GetParameter(“scalarBarLabel”) == “true”)
AttributeError: ‘VisualisationWidget’ object has no attribute ‘scalarBar’
Color legend has been hugely improved in recent Slicer versions (you can show multiple color legends, for more node types, works automatically for continuous and discrete colormaps, etc.) and it is now also simpler to show/hide it. See example in the script repository: Script repository — 3D Slicer documentation