当前位置: 首页>>代码示例>>Python>>正文


Python QwtPlotCurve.attach方法代码示例

本文整理汇总了Python中qwt.QwtPlotCurve.attach方法的典型用法代码示例。如果您正苦于以下问题:Python QwtPlotCurve.attach方法的具体用法?Python QwtPlotCurve.attach怎么用?Python QwtPlotCurve.attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qwt.QwtPlotCurve的用法示例。


在下文中一共展示了QwtPlotCurve.attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MyWindow(QtGui.QMainWindow):
    """
    This class implements a derivative of
    PyQt4.QtGui.QMainWindow, a complete application
    window, which can feature menus, submenus,
    status bar, etc. In this example, it uses
    few of those features.
    """

    def __init__(self, parent=None):
        """
        Constructor: creates an instance of MyWindow
        """
        #########################################
        # Necessary actions, which must be done #
        # for any project                       #
        #########################################
        # first, calling the ancestor's creator
        QtGui.QMainWindow.__init__(self, parent)
        # get the User Interface from the module UI_p1
        self.ui=Ui_MainWindow()
        # initialize the user interface
        self.ui.setupUi(self)
        #########################################
        # Custom actions, which can be written  #
        # in other ways for other projects.     #
        #########################################
        # aliases for some parts of the user interface
        self.plotWidget    = self.ui.qwtPlot
        self.measureButton = self.ui.measureButton
        self.closeButton   = self.ui.closeButton
        # connect methods to buttons' click signals
        self.measureButton.clicked.connect(self.measure)
        self.closeButton.clicked.connect(self.close)
        # initialize an empty curve for the plot widget
        self.curve         = QwtPlotCurve()
        self.curve.attach(self.plotWidget)
        return

    def measure(self):
        """
        This is a custom method to connect to the
        button for measurements.
        There is no need for another custom method,
        since the method "close" is already inherited
        from the ancestor class.
        """
        # create data for a curve with some fixed
        # and some random features
        import random
        x=np.arange(0,8,1e-2)      # abscissa: [0, 0.01, 0.02, ... 7.99]
        r=random.random()
        y=np.sin(x)+r*np.sin(3*x)  # calculated ordinate
        # feed new data into the curve
        self.curve.setData(x,y,len(x))
        # change the title of the plot on the fly
        self.plotWidget.setTitle("sin(x) + {} sin(3x)".format(r))
        # display the result
        self.plotWidget.replot()
        return
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:62,代码来源:p1.py

示例2: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
 def __init__(self, *args):
     QwtPlot.__init__(self, *args)
     self.setTitle("Cartesian Coordinate System Demo")
     # create a plot with a white canvas
     self.setCanvasBackground(Qt.white)
     # set plot layout
     self.plotLayout().setCanvasMargin(0)
     self.plotLayout().setAlignCanvasToScales(True)
     # attach a grid
     grid = QwtPlotGrid()
     grid.attach(self)
     grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
     # attach a x-axis
     xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft)
     xaxis.attach(self)
     self.enableAxis(QwtPlot.xBottom, False)
     # attach a y-axis
     yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom)
     yaxis.attach(self)
     self.enableAxis(QwtPlot.yLeft, False)
     # calculate 3 NumPy arrays
     x = np.arange(-2 * np.pi, 2 * np.pi, 0.01)
     y = np.pi * np.sin(x)
     z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x)
     # attach a curve
     curve = QwtPlotCurve("y = pi*sin(x)")
     curve.attach(self)
     curve.setPen(QPen(Qt.green, 2))
     curve.setData(x, y)
     # attach another curve
     curve = QwtPlotCurve("y = 4*pi*sin(x)*cos(x)**2")
     curve.attach(self)
     curve.setPen(QPen(Qt.black, 2))
     curve.setData(x, z)
     self.replot()
开发者ID:gyenney,项目名称:Tools,代码行数:37,代码来源:CartesianDemo.py

示例3: Example

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class Example(QtGui.QWidget):
    
    def __init__(self):
        super(Example, self).__init__()        
        self.initUI()


        self.current_y = 0

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.update_plot)
        self.timer.setInterval(1000/FREQ)
        self.timer.start()
        
        
    def initUI(self):
        
        self.setGeometry(300, 300, 1000, 1000)
        self.setWindowTitle('Icon')
        self.setWindowIcon(QtGui.QIcon('web.png'))
        self.plot = QwtPlot("Test", self)
        self.plot.resize(900, 900)
        self.curve = QwtPlotCurve("Curve 1")
        self.curve.attach(self.plot)
        self.show()

    def update_plot(self):
        self.curve.setData(x, ys[self.current_y])
        self.current_y = (self.current_y + 1) % YS
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:31,代码来源:test_pyqwt.py

示例4: __insertCurve

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
 def __insertCurve(self, orientation, color, base):
     curve = QwtPlotCurve()
     curve.attach(self)
     curve.setPen(QPen(color))
     curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.gray), QPen(color), QSize(8, 8)))
     fixed = base * np.ones(10, np.float)
     changing = np.arange(0, 95.0, 10.0, np.float) + 5.0
     if orientation == Qt.Horizontal:
         curve.setData(changing, fixed)
     else:
         curve.setData(fixed, changing)
开发者ID:petebachant,项目名称:python-qwt,代码行数:13,代码来源:EventFilterDemo.py

示例5: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MyWindow(QtGui.QMainWindow):
    """
    This class implements a derivative of
    PyQt4.QtGui.QMainWindow, a complete application
    window, which can feature menus, submenus,
    status bar, etc. In this example, it uses
    few of those features.
    """

    def __init__(self, parent=None):
        """
        Constructor: creates an instance of MyWindow
        """
        #########################################
        # Necessary actions, which must be done #
        # for any project                       #
        #########################################
        # first, calling the ancestor's creator
        QtGui.QMainWindow.__init__(self, parent)
        # get the User Interface from the module UI_p1
        self.ui=Ui_MainWindow()
        # initialize the user interface
        self.ui.setupUi(self)
        #########################################
        # Custom actions, which can be written  #
        # in other ways for other projects.     #
        #########################################
        # aliases for some parts of the user interface
        self.plotWidget    = self.ui.qwtPlot
        self.measureButton = self.ui.measureButton
        self.closeButton   = self.ui.closeButton
        # connect methods to buttons' click signals
        self.measureButton.clicked.connect(self.measure)
        self.closeButton.clicked.connect(self.close)
        # initialize an empty curve for the plot widget
        self.curve         = QwtPlotCurve()
        self.curve.attach(self.plotWidget)
        # initialize the driver for expEYES Junior
        self.p             = ej.open()
        return

    def measure(self):
        """
        This is a custom method to connect to the
        button for measurements.
        There is no need for another custom method,
        since the method "close" is already inherited
        from the ancestor class.
        """
        t,v = self.p.capture(1,1000,200)
        self.curve.setData(t,v,len(t))
        # display the result
        self.plotWidget.replot()
        return
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:56,代码来源:p2.py

示例6: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
 def __init__(self, parent=None):
     """
     Constructor: creates an instance of MyWindow
     """
     #########################################
     # Necessary actions, which must be done #
     # for any project                       #
     #########################################
     # first, calling the ancestor's creator
     QtGui.QMainWindow.__init__(self, parent)
     # get the User Interface from the module UI_p1
     self.ui=Ui_MainWindow()
     # initialize the user interface
     self.ui.setupUi(self)
     #########################################
     # Custom actions, which can be written  #
     # in other ways for other projects.     #
     #########################################
     # aliases for some parts of the user interface
     self.plotWidget    = self.ui.qwtPlot
     self.measureButton = self.ui.measureButton
     self.closeButton   = self.ui.closeButton
     # connect methods to buttons' click signals
     self.measureButton.clicked.connect(self.measure)
     self.closeButton.clicked.connect(self.close)
     # initialize 4 empty curves for the plot widget
     self.curves=[]
     colors=[
       QtGui.QColor("#000000"), #black
       QtGui.QColor("#ff0000"), #red
       QtGui.QColor("#0000ff"), #blue
       QtGui.QColor("#00cc00"), #dark green
     ]
     for i in range(4):
         c=QwtPlotCurve()
         c.setPen(colors[i])
         self.curves.append(c)
         c.attach(self.plotWidget)
     # initialize the driver for expEYES Junior
     # prevent an error if the box is not detected
     try:
         self.p             = ej.open()
         assert(self.p.fd)
         self.setWindowTitle("expEYES Junior found on port {}".format(
             self.p.fd.port
         ))
     except:
         self.setWindowTitle("ERROR: expEYES Junior NOT FOUND!")
         self.measureButton.setEnabled(False)
     return
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:52,代码来源:p1.py

示例7: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
 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')
     curve = QwtPlotCurve()
     curve.setPen(QPen(get_curve_color()))
     curve.setStyle(style)
     curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
     if symbol is not None:
         curve.setSymbol(symbol)
     curve.attach(self)
     curve.setData(xdata, ydata)
     self.replot()
开发者ID:gyenney,项目名称:Tools,代码行数:17,代码来源:CurveBenchmark.py

示例8: create_log_plot

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
def create_log_plot():
    plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)')
    plot.enableAxis(QwtPlot.xBottom)
    plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
    curve = QwtPlotCurve()
    curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
    pen = QPen(Qt.magenta)
    pen.setWidth(1.5)
    curve.setPen(pen)
    curve.attach(plot)
    x = np.arange(0.0, 10.0, 0.1)
    y = 10*np.cos(x)**2-.1
    print("y<=0:", y<=0)
    curve.setData(x, y)
    plot.replot()
    return plot
开发者ID:PierreRaybaut,项目名称:PythonQwt,代码行数:18,代码来源:LogCurveDemo.py

示例9: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        self.setTitle('ReallySimpleDemo.py')
        self.insertLegend(QwtLegend(), QwtPlot.RightLegend)
        self.setAxisTitle(QwtPlot.xBottom, 'x -->')
        self.setAxisTitle(QwtPlot.yLeft, 'y -->')
        self.enableAxis(self.xBottom)

        # insert a few curves
        cSin = QwtPlotCurve('y = sin(x)')
        cSin.setPen(QPen(Qt.red))
        cSin.attach(self)
        cCos = QwtPlotCurve('y = cos(x)')
        cCos.setPen(QPen(Qt.blue))
        cCos.attach(self)
        
        # make a Numeric array for the horizontal data
        x = np.arange(0.0, 10.0, 0.1)

        # initialize the data
        cSin.setData(x, np.sin(x))
        cCos.setData(x, np.cos(x))

        # insert a horizontal marker at y = 0
        mY = QwtPlotMarker()
        mY.setLabel(QwtText('y = 0'))
        mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        mY.setLineStyle(QwtPlotMarker.HLine)
        mY.setYValue(0.0)
        mY.attach(self)

        # insert a vertical marker at x = 2 pi
        mX = QwtPlotMarker()
        mX.setLabel(QwtText('x = 2 pi'))
        mX.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        mX.setLineStyle(QwtPlotMarker.VLine)
        mX.setXValue(2*np.pi)
        mX.attach(self)

        # replot
        self.replot()
开发者ID:gyenney,项目名称:Tools,代码行数:43,代码来源:ReallySimpleDemo.py

示例10: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        layout = QGridLayout(self)        
        # try to create a plot for SciPy arrays

        # make a curve and copy the data
        numpy_curve = QwtPlotCurve('y = lorentzian(x)')
        x = np.arange(0.0, 10.0, 0.01)
        y = lorentzian(x)
        numpy_curve.setData(x, y)
        # here, we know we can plot NumPy arrays
        numpy_plot = QwtPlot(self)
        numpy_plot.setTitle('numpy array')
        numpy_plot.setCanvasBackground(Qt.white)
        numpy_plot.plotLayout().setCanvasMargin(0)
        numpy_plot.plotLayout().setAlignCanvasToScales(True)
        # insert a curve and make it red
        numpy_curve.attach(numpy_plot)
        numpy_curve.setPen(QPen(Qt.red))
        layout.addWidget(numpy_plot, 0, 0)
        numpy_plot.replot()

        # create a plot widget for lists of Python floats
        list_plot = QwtPlot(self)
        list_plot.setTitle('Python list')
        list_plot.setCanvasBackground(Qt.white)
        list_plot.plotLayout().setCanvasMargin(0)
        list_plot.plotLayout().setAlignCanvasToScales(True)
        x = drange(0.0, 10.0, 0.01)
        y = [lorentzian(item) for item in x]
        # insert a curve, make it red and copy the lists
        list_curve = QwtPlotCurve('y = lorentzian(x)')
        list_curve.attach(list_plot)
        list_curve.setPen(QPen(Qt.red))
        list_curve.setData(x, y)
        layout.addWidget(list_plot, 0, 1)
        list_plot.replot()
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:39,代码来源:MultiDemo.py

示例11: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MyWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        # connect methods to buttons' click signals
        self.ui.wakeUpButton.clicked.connect(self.wakeUp)
        self.ui.stopButton.clicked.connect(self.stop)
        self.ui.closeButton.clicked.connect(self.close)
        self.ui.saveButton.clicked.connect(self.save)
        self.ui.immediateButton.clicked.connect(self.immediate)
        self.ui.finalButton.clicked.connect(self.final)
        self.ui.fitButton.clicked.connect(self.fit)
        self.ui.action_Save_Ctrl_S.triggered.connect(self.save)
        self.ui.action_Quit_Ctrl_Q.triggered.connect(self.close)
        self.ui.actionManual.triggered.connect(self.manual)
        self.ui.actionAbout.triggered.connect(self.about)
        # create a timer
        self.stopTime=time.time()
        self.timer=QtCore.QTimer()
        # connect the timer to the "tick" callback method
        self.timer.timeout.connect(self.tick)
        # 20 times per second
        self.timer.start(50)
        # initialize an empty curve for the plot widget
        self.curve         = QwtPlotCurve()
        self.curve.attach(self.ui.qwtPlot)
        # expEYESdetection and initialization
        try:
            self.p             = ej.open()
            assert(self.p.fd)
            self.setWindowTitle("expEYES Junior found on port {}".format(
                self.p.fd.port
            ))
        except:
            self.setWindowTitle("ERROR: expEYES Junior NOT FOUND!")
            self.wakeUpButton.setEnabled(False)
        # custom properties
        self.isImmediate=True
        return
        
    def immediate(self):
        self.isImmediate=True
        return
        
    def final(self):
        self.isImmediate=False
        return

    def wakeUp(self):
        # get the duration of the experiment in s
        duration = float(self.ui.durationEdit.text())
        if duration < 0.5: # "final" mode is mandatory
            self.ui.finalButton.setChecked(True)
            self.isImmediate=False
        elif duration > 3.5: # "immediate" mode is mandatory
            self.ui.immediateButton.setChecked(True)
            self.isImmediate=True
        self.ui.qwtPlot.setAxisScale(QwtPlot.xBottom, 0, duration)
        if self.isImmediate:
            now=time.time()
            self.t=[]
            self.v=[]
            self.curve.setData([],[],0)
            self.startTime=now
            self.stopTime=now+duration
            # now the curve will grow until time.time >= self.stopTime
            # thanks to self.timer's timeout events
        else:
            samples  = 1800 # maximum sample number with 8 bit precision
            # ensure that samples * delay will be slightly bigger than duration
            delay=1+int(duration*1e6/1800)
            t, self.v = self.p.capture(1,samples, delay)
            self.t=[1e-3*date for date in t] # convert ms to s
            self.curve.setData(self.t, self.v, len(self.t))
        return

    def tick(self):
        """ Callback for the timeout events """
        t=time.time()
        if t < self.stopTime:
            v = self.p.get_voltage(1)
            self.t.append(time.time()-self.startTime)
            self.v.append(v)
            self.curve.setData(self.t, self.v, len(self.t))
        return
            
        
    def notImplemented(self):
        msg=QtGui.QMessageBox(QtGui.QMessageBox.Warning,"Sorry",
                              "not yet implemented", )
        msg.exec_()
        return

    stop=save=fit=manual=about=notImplemented
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:97,代码来源:oscill3.py

示例12: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MyWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        # connect methods to buttons' click signals
        self.ui.wakeUpButton.clicked.connect(self.wakeUp)
        self.ui.stopButton.clicked.connect(self.stop)
        self.ui.closeButton.clicked.connect(self.close)
        self.ui.saveButton.clicked.connect(self.save)
        self.ui.immediateButton.clicked.connect(self.immediate)
        self.ui.finalButton.clicked.connect(self.final)
        self.ui.fitButton.clicked.connect(self.fit)
        self.ui.action_Save_Ctrl_S.triggered.connect(self.save)
        self.ui.action_Quit_Ctrl_Q.triggered.connect(self.close)
        self.ui.actionManual.triggered.connect(self.manual)
        self.ui.actionAbout.triggered.connect(self.about)
        self.ui.durationEdit.textChanged.connect(self.durationChanged)
        # create a timer
        self.stopTime=time.time()
        self.timer=QtCore.QTimer()
        # connect the timer to the "tick" callback method
        self.timer.timeout.connect(self.tick)
        # 20 times per second
        self.timer.start(50)
        # initialize an empty curve for the plot widget
        self.curve         = QwtPlotCurve()
        self.curve0        = QwtPlotCurve()
        self.fitCurve1     = QwtPlotCurve()
        self.fitCurve2     = QwtPlotCurve()
        self.fitCurve3     = QwtPlotCurve()
        self.curve.attach(self.ui.qwtPlot)
        self.curve0.attach(self.ui.qwtPlot)
        self.fitCurve1.attach(self.ui.qwtPlot)
        self.fitCurve2.attach(self.ui.qwtPlot)
        self.fitCurve3.attach(self.ui.qwtPlot)
        # adjust the axis scales based on duration = 15 s
        self.durationChanged(15, ampl=5)
        # set the maxvalue for the threshold rate (in V/s)
        self.maxthreshold=150/15 # = 150/duration
        # expEYESdetection and initialization
        try:
            self.p             = ej.open()
            assert(self.p.fd)
            self.setWindowTitle("expEYES Junior found on port {}".format(
                self.p.fd.port
            ))
        except:
            self.setWindowTitle("ERROR: expEYES Junior NOT FOUND!")
            self.ui.wakeUpButton.setEnabled(False)
        # custom properties
        self.isImmediate=True
        return
        
    def durationChanged(self, value, ampl=0):
        """
        Callback function for changed in ui.durationEdit
        @param value the widget's value in case of an event
        @param ampl an amplitudes (defaults to 0)
        """
        try:
            duration=float(value)
        except:
            return
        # set the axis scales for the plot widget
        self.ui.qwtPlot.setAxisScale(QwtPlot.xBottom, 0, duration)
        # draw the "zero" line
        small=duration/1e6
        self.curve0.setData([0, small, 2*small, 3*small, duration],
                            [0, ampl,  -ampl,   0,       0], 5)
        # update the threshold rate 
        self.maxThreshold=150/duration
        self.ui.thresholdLabel.setText("{} V/s".format(self.maxThreshold))
        # erase fit curves
        self.fitCurve1.setData([],[],0)
        self.fitCurve2.setData([],[],0)
        self.fitCurve3.setData([],[],0)
        return
        
    def immediate(self):
        self.isImmediate=True
        return
        
    def final(self):
        self.isImmediate=False
        return
        
    def stop(self):
        # in "final" mode, this has no effect
        # in "immediate" mode, it forces the plot to
        # stop at the next tick call.
        self.stopTime=time.time()
        return

    def save(self):
        filename=self.ui.fileNameEdit.text()
        with open(filename,"w") as outfile:
            for i in range(len(self.t)):
                outfile.write("{} {}\n".format(
                   self.t[i], self.v[i]
#.........这里部分代码省略.........
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:103,代码来源:oscill4.py

示例13: MapDemo

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MapDemo(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.plot = QwtPlot(self)
        self.plot.setTitle("A Simple Map Demonstration")
        self.plot.setCanvasBackground(Qt.white)
        self.plot.setAxisTitle(QwtPlot.xBottom, "x")
        self.plot.setAxisTitle(QwtPlot.yLeft, "y")    
        self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0)
        self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0)
        self.setCentralWidget(self.plot)
        # Initialize map data
        self.count = self.i = 1000
        self.xs = np.zeros(self.count, np.float)
        self.ys = np.zeros(self.count, np.float)
        self.kappa = 0.2
        self.curve = QwtPlotCurve("Map")
        self.curve.attach(self.plot)
        self.curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                           QBrush(Qt.red),
                                           QPen(Qt.blue),
                                           QSize(5, 5)))
        self.curve.setPen(QPen(Qt.cyan))
        toolBar = QToolBar(self)
        self.addToolBar(toolBar)
        # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz)
        self.ticks = 10
        self.tid = self.startTimer(self.ticks)
        self.timer_tic = None
        self.user_tic = None
        self.system_tic = None    
        self.plot.replot()

    def setTicks(self, ticks):
        self.i = self.count
        self.ticks = int(ticks)
        self.killTimer(self.tid)
        self.tid = self.startTimer(ticks)
        
    def resizeEvent(self, event):
        self.plot.resize(event.size())
        self.plot.move(0, 0)

    def moreData(self):
        if self.i == self.count:
            self.i = 0
            self.x = random.random()
            self.y = random.random()
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1
            chunks = []
            self.timer_toc = time.time()
            if self.timer_tic:
                chunks.append("wall: %s s." % (self.timer_toc-self.timer_tic))
                print(' '.join(chunks))
            self.timer_tic = self.timer_toc
        else:
            self.x, self.y = standard_map(self.x, self.y, self.kappa)
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1
        
    def timerEvent(self, e):
        self.moreData()
        self.curve.setData(self.xs[:self.i], self.ys[:self.i])
        self.plot.replot()
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:69,代码来源:MapDemo.py

示例14: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
class MyWindow(QtGui.QMainWindow):
    """
    This class implements a derivative of
    PyQt4.QtGui.QMainWindow, a complete application
    window, which can feature menus, submenus,
    status bar, etc. In this example, it uses
    few of those features.
    """

    def __init__(self, parent=None):
        """
        Constructor: creates an instance of MyWindow
        """
        #########################################
        # Necessary actions, which must be done #
        # for any project                       #
        #########################################
        # first, calling the ancestor's creator
        QtGui.QMainWindow.__init__(self, parent)
        # get the User Interface from the module UI_p1
        self.ui=Ui_MainWindow()
        # initialize the user interface
        self.ui.setupUi(self)
        #########################################
        # Custom actions, which can be written  #
        # in other ways for other projects.     #
        #########################################
        # aliases for some parts of the user interface
        self.plotWidget    = self.ui.qwtPlot
        self.measureButton = self.ui.measureButton
        self.closeButton   = self.ui.closeButton
        # connect methods to buttons' click signals
        self.measureButton.clicked.connect(self.measure)
        self.closeButton.clicked.connect(self.close)
        # initialize an empty curve for the plot widget
        self.curve         = QwtPlotCurve()
        self.curve.attach(self.plotWidget)
        # initialize the driver for expEYES Junior
        # prevent an error if the box is not detected
        try:
            self.p             = ej.open()
            assert(self.p.fd)
            self.setWindowTitle("expEYES Junior found on port {}".format(
                self.p.fd.port
            ))
        except:
            self.setWindowTitle("ERROR: expEYES Junior NOT FOUND!")
            self.measureButton.setEnabled(False)
        return

    def measure(self):
        """
        This is a custom method to connect to the
        button for measurements.
        There is no need for another custom method,
        since the method "close" is already inherited
        from the ancestor class.
        """
        sample=int(self.ui.samplesEdit.text())
        delay=int(self.ui.delayEdit.text())
        channel=self.inputCode()
        duration=int(sample*delay/1000) # in ms
        self.ui.statusbar.showMessage(
            "Measuring data for {} seconds, please be patient...".format(duration/1000),
            duration
        )
        self.ui.statusbar.repaint() # immediately shows the status
        t,v = self.p.capture(channel, sample, delay)
        self.curve.setData(t,v,len(t))
        # display the result
        self.plotWidget.replot()
        return

    def inputCode(self):
        """
        considers the radio buttons
        @return the code for the selected input channel
        """
        value={
            "A1":  1,
            "A2":  2,
            "IN1": 3,
            "IN2": 4,
            "SEN": 5,
        }
        radios=[r for r in self.ui.groupBox.children()
                  if isinstance(r, QtGui.QRadioButton)]
        for r in radios:
            if r.isChecked():
                return value[r.text().strip()]
        return 0
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:93,代码来源:p1.py

示例15: QApplication

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import attach [as 别名]
# -*- coding: utf-8 -*-
__author__ = 'Valeriy'

from qwt.qt.QtGui import QApplication
from qwt import QwtPlot, QwtPlotCurve
import numpy as np

app = QApplication([])

# x = [1,2,3,4,5,6,7,8,9]
# y1 = [3.2, 5.1 ,7.0, 4.24, 4.41, 8.34, 2.21, 5.657, 6.1]


x = []
y1 = []


my_plot = QwtPlot("Two curves")
curve1 = QwtPlotCurve("Curve 1")
my_plot.resize(600, 300)

curve1.setData(x, y1)
curve1.attach(my_plot)
# my_plot.replot()
my_plot.show()

app.exec_()

# SELECT PrepData FROM= Pdata WHERE ((PNameId=2) AND (SNameId = 14) AND (YearId=2012))
开发者ID:valeriy67,项目名称:Cquality,代码行数:31,代码来源:temp.py


注:本文中的qwt.QwtPlotCurve.attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。