1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| import sys import pyqtgraph as pg from PyQt5.QtWidgets import QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QWidget from PyQt5.QtGui import QColor
class Window(QMainWindow): def __init__(self, title): super(Window, self).__init__()
self.title = title self.setWindowTitle(self.title) palette = self.palette() palette.setColor(self.backgroundRole(), QColor(255, 255, 255)) self.setPalette(palette) self.setAutoFillBackground(True) self.resize(1920, 1080) self.plot = pg.PlotWidget() self.color = QColor(255, 228, 196) self.curve = self.plot.plot( pen=pg.mkPen(color=self.color, width=1) ) self.curve.setData(X, Y) self.plot.setBackground('w') self.plot.setTitle('Your Title', color=self.O2_color, size='12pt') self.plot.setLabel('left', '%') self.plot.setLabel('bottom', 'Time(s)') self.plot.setYRange(25, 14) layout_vs = QVBoxLayout() layout_hs = QHBoxLayout() layout_vs.addWidget(self.plot) layout_vs.addWidget(self.plot) layout_hs.addLayout(layout_vs) layout_hs.addLayout(layout_vs) self.central_widget = QWidget() self.central_widget.setLayout(layout_hs) self.setCentralWidget(self.central_widget) if __name__ == '__main__': app = QApplication(sys.argv) win = Window('PyQt') win.show() sys.exit(app.exec_())
|