from PyQt5.QtWidgets import *
import pyqtgraph as pg
import sysclass MainWindow(QWidget):def __init__(self):super().__init__()self.setWindowTitle('pyqtgraph作图示例')# 创建 GraphicsLayoutWidget 对象self.pw = pg.GraphicsLayoutWidget()self.pw.setBackground('w')# 绘图对象1plot1 = self.pw.addPlot()plot1.setTitle("订单数量1", color='#008080', size='12pt')x1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]y1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]bg1 = pg.BarGraphItem(x=x1, height=y1, width=0.3, brush='r')# 添加到界面上plot1.addItem(bg1)# 绘图对象2plot2 = self.pw.addPlot()plot2.setTitle("订单数量2", color='#008080', size='12pt')x2 = [0.33, 1.33, 2.33, 3.33, 4.33, 5.33, 6.33, 7.33, 8.33, 9.33]y2 = [0.33, 1.33, 2.33, 3.33, 4.33, 5.33, 6.33, 7.33, 8.33, 9.33]bg2 = pg.BarGraphItem(x=x2, height=y2, width=0.3, brush='g')# 添加到界面上plot2.addItem(bg2)# 创建其他Qt控件okButton = QPushButton("OK")lineEdit = QLineEdit('点击信息')# 水平layout里面放 edit 和 buttonhbox = QHBoxLayout()hbox.addWidget(lineEdit)hbox.addWidget(okButton)# 垂直layout里面放 pyqtgraph图表控件 和 前面的水平layoutvbox = QVBoxLayout()vbox.addWidget(self.pw)vbox.addLayout(hbox)# 设置全局layoutself.setLayout(vbox)if __name__ == '__main__':app = QApplication(sys.argv)main = MainWindow()main.show()app.exec_()