def __init__(self, title, xdata, ydata, style, symbol=None, *args): super(BMPlot, self).__init__(*args) self.setMinimumSize(200, 200) self.setTitle(title) self.setAxisTitle(QwtPlot.xBottom, "x") self.setAxisTitle(QwtPlot.yLeft, "y") self.curve_nb = 0 for idx in range(1, 11): self.curve_nb += 1 QwtPlotCurve.make( xdata, ydata * idx, style=style, symbol=symbol, linecolor=get_curve_color(), antialiased=True, plot=self, ) self.replot()
def __init__(self, parent=None): super(VerticalPlot, self).__init__(parent) self.setWindowTitle("PyQwt" if USE_PYQWT5 else "PythonQwt") self.enableAxis(self.xTop, True) self.enableAxis(self.yRight, True) y = np.linspace(0, 10, 500) curve1 = QwtPlotCurve.make(np.sin(y), y, title="Test Curve 1") curve2 = QwtPlotCurve.make(y**3, y, title="Test Curve 2") if USE_PYQWT5: # PyQwt curve2.setAxis(self.xTop, self.yRight) self.canvas().setFrameStyle(0) self.plotLayout().setCanvasMargin(0) self.axisWidget(QwtPlot.yLeft).setMargin(0) self.axisWidget(QwtPlot.xTop).setMargin(0) self.axisWidget(QwtPlot.yRight).setMargin(0) self.axisWidget(QwtPlot.xBottom).setMargin(0) else: # PythonQwt curve2.setAxes(self.xTop, self.yRight) for item, col, xa, ya in ( (curve1, Qt.green, self.xBottom, self.yLeft), (curve2, Qt.red, self.xTop, self.yRight), ): if not USE_PYQWT5: # PythonQwt item.setOrientation(Qt.Vertical) item.attach(self) item.setPen(QPen(col)) for axis_id in xa, ya: palette = self.axisWidget(axis_id).palette() palette.setColor(QPalette.WindowText, QColor(col)) palette.setColor(QPalette.Text, QColor(col)) self.axisWidget(axis_id).setPalette(palette) ticks_font = self.axisFont(axis_id) self.setAxisFont(axis_id, ticks_font) self.marker = QwtPlotMarker.make(0, 5, plot=self)