from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
pg.setConfigOption('background', (255, 255, 200))
pg.setConfigOption('foreground', 'k')
app = QtGui.QApplication([])
mw = QtGui.QMainWindow()
mw.setWindowTitle('pyqtgraph example: PlotWidget')
mw.resize(800, 800)
cw = QtGui.QWidget()
mw.setCentralWidget(cw)
l = QtGui.QVBoxLayout()
cw.setLayout(l)
pw = pg.PlotWidget(name='Plot1') # giving the plots names allows us to link their axes together
p1 = pw.plotItem.plot([1, 2, 5], pen='r')
pw.plotItem.showGrid(y=True)
def changeBackground():
global pw
pw.plotItem.vb.setBackgroundColor(np.random.randint(low=0, high=255, size=(3,)))
b = QtGui.QPushButton("change background color")
b.clicked.connect(changeBackground)
l.addWidget(b)
l.addWidget(pw)
mw.show()
# Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
pw.setBackground(np.random.randint(low=0, high=255, size=(3,)))
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
pg.setConfigOption('background', (255, 255, 200))
pg.setConfigOption('foreground', 'k')
app = QtGui.QApplication([])
mw = QtGui.QMainWindow()
mw.setWindowTitle('pyqtgraph example: PlotWidget')
mw.resize(800, 800)
cw = QtGui.QWidget()
mw.setCentralWidget(cw)
l = QtGui.QVBoxLayout()
cw.setLayout(l)
pw = pg.PlotWidget(name='Plot1') # giving the plots names allows us to link their axes together
p1 = pw.plotItem.plot([1, 2, 5], pen='r')
pw.plotItem.showGrid(y=True)
def changeBackground():
global pw
pw.plotItem.vb.setBackgroundColor((255, 255, 255, 255))
top = pw.plotItem.getAxis("top")
bottom = pw.plotItem.getAxis("bottom")
left = pw.plotItem.getAxis("left")
right = pw.plotItem.getAxis("right")
top.setZValue(0)
bottom.setZValue(0)
left.setZValue(0)
right.setZValue(0)
b = QtGui.QPushButton("change background color")
b.clicked.connect(changeBackground)
l.addWidget(b)
l.addWidget(pw)
mw.show()
# Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()