![](https://img2023.cnblogs.com/blog/1008336/202303/1008336-20230329002333682-258764659.png)
from PyQt5 import QtWidgets, uic #from PyQt5.QtWidgets import QPushButton,QWidget,QApplication,QGridLayout,QListWidget,QLineEdit import pyqtgraph as pg import sys import numpy as np class Example(QtWidgets.QMainWindow): def __init__(self): super(Example, self).__init__() uic.loadUi('mian1.ui', self) self.initUI() def initUI(self): self.linePlot() self.three_curves() pass def linePlot(self): plt1 = pg.PlotWidget() plt1.plot([i for i in range(10)], [i * i for i in range(10)]) self.verticalLayout1.addWidget(plt1) def three_curves(self): plt2 = pg.PlotWidget(title="Three plot curves") x = np.arange(1000) y = np.random.normal(size=(3, 1000)) for i in range(3): plt2.plot(x, y[i], pen=(i, 3)) ## setting pen=(i,3) 自动创建3个不同颜色的笔 self.verticalLayout2.addWidget(plt2) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) ex = Example() ex.show() sys.exit(app.exec_())