How to change the background color of plot view

my custom application has a dark color style , how to change the plot view background color to the dark color style
the demo ui below
image

This worked for me:

lm = slicer.app.layoutManager()
pw0 = lm.plotWidget(0)
pv = pw0.plotView()
ch = pv.chart()
bb = ch.GetBackgroundBrush()
bb.SetColor(0,0,128)
ch.SetBackgroundBrush(bb)
2 Likes

thank you cpinter
this is the only code i find useful
do you know how to change the color of the Coordinate axis?

I’d look along the same lines. In the chart MRML node, the plot view (subclass of ctkVTKChartView), and the VTK chart class. If there is such a function in said classes use that, if there isn’t, then it is probably not supported.

thank you very much@cpinter