newplotview.py 1.54 KB
Newer Older
1 2 3 4 5 6
#!/usr/bin/python3.4
# -*- coding: utf-8 -*-

"""
    Real time plot widget
"""
7 8 9 10 11 12
import pyqtgraph as Pg
import numpy as np
from PyQt4 import QtGui, QtCore

Pg.setConfigOption('background','w')
Pg.setConfigOption('foreground','k')
13 14 15 16 17

class NewPlotWindow(QtGui.QWidget):
    def __init__(self, pattern = None):
        super(NewPlotWindow, self).__init__()

18
class PlotWidget(Pg.GraphicsLayoutWidget):
19 20 21 22 23
    def __init__(self):
        super(PlotWidget, self).__init__()
        self.initPlot()

    def initPlot(self):
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 53 54 55 56 57 58 59
        p1 = self.addPlot(color=(255,255,255))
        p1.setMenuEnabled(False)
        p1.hideButtons()
        p1.vb.setMouseEnabled(False, False)
        p1.setRange(xRange=[0,100])

        data1 = np.random.normal(size=300)
        curve1 = p1.plot(data1, pen=(0,0,0))
        print(p1.__dict__)

    def update():
        data1[:-1] = data1[1:]  # shift data in the array one sample left
                                # (see also: np.roll)
        data1[-1] = np.random.normal()
        curve1.setData(data1)

        ptr1 += 1
        curve2.setData(data1)
        curve2.setPos(ptr1, 0)

class RealTimePlotItem(Pg.PlotItem):
    def __init__(self, **kwargs):
        super(RealTimePlotItem, self).__init__()
        self.setMenuEnabled(False)
        self.hideButtons()
        self.vb.setMouseEnabled(False, False)
        self.data_points = 500
        self.curves = list()
        
    def update(self):
        pass

class RealTimePlotCurve():
    def __init__(self, plot_item=None):
        self.color = list()
        self.plot_item = plot_item