pythonscatter-plotpyqtgraphsetbackground

Issue in setting the background color in pyqtgraph


I've got an issue when using the pyqtgraph module in python. When I put a white background color to a glscatterplot, the scatter dots just vanish. It is like if the color of background was added to the color of the scatterplot therefore everything is white. Here is a piece of the code I use:

w = gl.GLViewWidget()
w.setBackgroundColor('w')
w.show()
sp3 = gl.GLScatterPlotItem(pos=np.transpose(pos3), color=rgba_img, size=1, pxMode=False)
w.addItem(sp3)

If I replace ('w') by ('k') in the setBackgroundColor method the color of scatter is fine and the background is black. Did anyone else ever get this issue?


Solution

  • I think the reason is that you haven't set the foreground colour. try:

    import pyqtgraph as pg
    
    pg.setConfigOption('background', 'w')
    pg.setConfigOption('foreground', 'k')