0

I layout 4 plots using pyqtgraph, load a little big data of np.random.normal(size=10000000), and link all x axis, but when I zoom a plot, it crased, why???

the consol output is Process finished with exit code -1073741819 (0xC0000005)

this is my test code.

from sys import argv, exit
import numpy as np
from PySide2.QtWidgets import QWidget, QHBoxLayout, QApplication
from pyqtgraph import GraphicsLayoutWidget, PlotDataItem


class CurveWidget(QWidget):

    def __init__(self, parent=None, *args, **kwargs):
        """init parameter"""
        super(CurveWidget, self).__init__(parent)
        self._setup_ui()

    def _setup_ui(self):
        """setup ui of realtime draw"""
        self._h_layout = QHBoxLayout(self)
        self._h_layout.setContentsMargins(0, 0, 0, 0)
        self._view = GraphicsLayoutWidget(self)
        self._plot1 = self._view.addPlot(0, 0)
        self._plot2 = self._view.addPlot(0, 1)
        self._plot3 = self._view.addPlot(1, 0)
        self._plot4 = self._view.addPlot(1, 1)

        self._plot1.showGrid(x=True, y=True)
        self._plot2.showGrid(x=True, y=True)
        self._plot3.showGrid(x=True, y=True)
        self._plot4.showGrid(x=True, y=True)
        self._vb1 = self._plot1.vb
        self._vb2 = self._plot2.vb
        self._vb3 = self._plot3.vb
        self._vb4 = self._plot4.vb

        self._h_layout.addWidget(self._view)

        # self._curve = PlotCurveItem(pen=({'color': (0, 1), 'width': 1}), skipFiniteCheck=True)
        self._curve1 = PlotDataItem(pen=({'color': (0, 1), 'width': 1}), skipFiniteCheck=True, autoDownsample=True)
        self._curve2 = PlotDataItem(pen=({'color': (0, 1), 'width': 1}), skipFiniteCheck=True, autoDownsample=True)
        self._curve3 = PlotDataItem(pen=({'color': (0, 1), 'width': 1}), skipFiniteCheck=True, autoDownsample=True)
        self._curve4 = PlotDataItem(pen=({'color': (0, 1), 'width': 1}), skipFiniteCheck=True, autoDownsample=True)
        self._vb1.addItem(self._curve1)
        self._vb2.addItem(self._curve2)
        self._vb3.addItem(self._curve3)
        self._vb4.addItem(self._curve4)

        self._vb2.setXLink(self._vb1)
        self._vb3.setXLink(self._vb1)
        self._vb4.setXLink(self._vb1)

        self._curve1.setData(np.random.normal(size=10000000))
        self._curve2.setData(np.random.normal(size=10000000))
        self._curve3.setData(np.random.normal(size=10000000))
        self._curve4.setData(np.random.normal(size=10000000))


if __name__ == "__main__":
    app = QApplication.instance()
    if app is None:
        app = QApplication(argv)
    win = CurveWidget()
    win.show()
    exit(app.exec_())

0 Answers0