Operating system: windows
Slicer version: 4.11.0
Expected behavior: Hide legends by LegendVisibilityOff()
Actual behavior: can’t turn legends off via cripts
I used the help file via the site: https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots
and get chartplot there:
plotChartNode_ID = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLPlotChartNode”)
but via running python scritps:
cn = slicer.util.getNodesByClass('vtkMRMLPlotChartNode')
tt = cn
I failed to hide legends.
But while I typed exactly the same commands inside the “Python Interactor”, it worked well to hide legends.
Why? Thanks a lot.
Probably you have several chart nodes and in the code snippet you only modify the first one, which may not be the one you are interested in. You can get the displayed chart node from the plot widget, and the widget from the layout manager.
Thanks a lot. Basically I understand what you mentioned.
But after I did set up the visibility to be false by
plotChartNode_ID.SetLegendVisibility(False) and then I checked if it was false as printed out as follows ==> LegendVisibility: false. So that means, in the python scripts there, somehow, sometime the legend was set to be “false” not-shown there. But later somehow something brought it back to be “true” shown there.
While the legend was still shown there until I did manual commands from the “python interactor” to do again, since, checking from “python interactor”, I saw the “legendVisibility: True” there before I did manual commands.
printed inside scripts after I did set it to be “False”.
in “python interactor”, before I manually changed to be “False”.
So please help check if there is kind of glitch there for the legend-visibility. Thanks a lot.
thanks a lot, @Alex_Vergara
I am trying to test your way. LOL.
I did try applying your way. I have to say it’s kind of the same case I described. That means, while I clicked the checkbox on or off to show or hide legends, it worked just perfectly fine. But that’s not what I need. Since I would have hundreds times of screen-shot of the plots, one time/one plot for one sample, I need try to hide legends in the plot while I capture the plot. I am pretty sure of that there is some glitch inside something/somewhere.
I will try something else to see if I may skip this issue.
I think there were some extra touching parameters of legends there to get it from False to True.
So right after set it as False, it’s just good there to hide legends!