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: https://github.com/Slicer/Slicer/pull/235, 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
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