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


Python QwtPlotCurve.setPen方法代码示例

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


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

示例1: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例2: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.xMap = QwtScaleMap()
        self.xMap.setScaleInterval(-0.5, 10.5)
        self.yMap = QwtScaleMap()
        self.yMap.setScaleInterval(-1.1, 1.1)

        # frame style
        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        # calculate values
        self.x = np.arange(0, 10.0, 10.0/27)
        self.y = np.sin(self.x)*np.cos(2*self.x)

        # make curves with different styles
        self.curves = []
        self.titles = []

        # curve 2
        self.titles.append('Style: Lines, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        self.curves.append(curve)

        # attach data, using Numeric
        for curve in self.curves:
            curve.setData(self.x, self.y)
开发者ID:valeriy67,项目名称:Cquality,代码行数:33,代码来源:tempdraw.py

示例3: __insertCurve

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例4: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        p = QPalette()
        p.setColor(self.backgroundRole(), QColor(30, 30, 50))
        self.setPalette(p)
        # make curves and maps
        self.tuples = []
        # curve 1
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(150, 150, 200), 2))
        curve.setStyle(QwtPlotCurve.Lines)
        curve.setSymbol(QwtSymbol(QwtSymbol.XCross,
                                      QBrush(),
                                      QPen(Qt.yellow, 2),
                                      QSize(7, 7)))
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -1.5, 1.5),
                            QwtScaleMap(0, 100, 0.0, 2*np.pi)))
        # curve 2
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(200, 150, 50),
                                1,
                                Qt.DashDotDotLine))
        curve.setStyle(QwtPlotCurve.Sticks)
        curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                      QBrush(Qt.blue),
                                      QPen(Qt.yellow),
                                      QSize(5, 5)))
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, 0.0, 2*np.pi),
                            QwtScaleMap(0, 100, -3.0, 1.1)))
        # curve 3
        curve = QwtPlotCurve()
        curve.setPen(QPen(QColor(100, 200, 150)))
        curve.setStyle(QwtPlotCurve.Lines)
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -1.1, 3.0),
                            QwtScaleMap(0, 100, -1.1, 3.0)))
        # curve 4
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.red))
        curve.setStyle(QwtPlotCurve.Lines)
        self.tuples.append((curve,
                            QwtScaleMap(0, 100, -5.0, 1.1),
                            QwtScaleMap(0, 100, -1.1, 5.0)))
        # data
        self.phase = 0.0
        self.base = np.arange(0.0, 2.01*np.pi, 2*np.pi/(USize-1))
        self.uval = np.cos(self.base)
        self.vval = np.sin(self.base)
        self.uval[1::2] *= 0.5
        self.vval[1::2] *= 0.5
        self.newValues()
        # start timer
        self.tid = self.startTimer(250)
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:62,代码来源:CurveDemo2.py

示例5: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例6: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例7: create_log_plot

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例8: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例9: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例10: BodePlot

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
class BodePlot(QwtPlot):

    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setTitle('Frequency Response of a 2<sup>nd</sup>-order System')
        self.setCanvasBackground(Qt.darkBlue)

        # legend
        legend = QwtLegend()
        legend.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.insertLegend(legend, QwtPlot.BottomLegend)

        # grid
        self.grid = QwtPlotGrid()
        self.grid.enableXMin(True)
        self.grid.attach(self)

        # axes
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.xBottom, '\u03c9/\u03c9<sub>0</sub>')
        self.setAxisTitle(QwtPlot.yLeft, 'Amplitude [dB]')
        self.setAxisTitle(QwtPlot.yRight, 'Phase [\u00b0]')

        self.setAxisMaxMajor(QwtPlot.xBottom, 6)
        self.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.setAxisScaleEngine(QwtPlot.xBottom, QwtLogScaleEngine())

        # curves
        self.curve1 = QwtPlotCurve('Amplitude')
        self.curve1.setRenderHint(QwtPlotItem.RenderAntialiased);
        self.curve1.setPen(QPen(Qt.yellow))
        self.curve1.setYAxis(QwtPlot.yLeft)
        self.curve1.attach(self)
        
        self.curve2 = QwtPlotCurve('Phase')
        self.curve2.setRenderHint(QwtPlotItem.RenderAntialiased);
        self.curve2.setPen(QPen(Qt.cyan))
        self.curve2.setYAxis(QwtPlot.yRight)
        self.curve2.attach(self)

        # alias
        fn = self.fontInfo().family()

        # marker
        self.dB3Marker = m = QwtPlotMarker()
        m.setValue(0.0, 0.0)
        m.setLineStyle(QwtPlotMarker.VLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.green, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.green)
        text.setBackgroundBrush(Qt.red)
        text.setFont(QFont(fn, 12, QFont.Bold))
        m.setLabel(text)
        m.attach(self)

        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.red, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))
        text.setFont(QFont(fn, 12, QFont.Bold))
        
        m.setLabel(text)
        m.setSymbol(QwtSymbol(QwtSymbol.Diamond,
                              QBrush(Qt.yellow),
                              QPen(Qt.green),
                              QSize(7,7)))
        m.attach(self)

        # text marker
        m = QwtPlotMarker()
        m.setValue(0.1, -20.0)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText(
            '[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]'
            '<sup>-1</sup>'
            )
        text.setFont(QFont(fn, 12, QFont.Bold))
        text.setColor(Qt.blue)
        text.setBackgroundBrush(QBrush(Qt.yellow))
        text.setBorderPen(QPen(Qt.red, 2))
        m.setLabel(text)
        m.attach(self)

        self.setDamp(0.01)

    def showData(self, frequency, amplitude, phase):
        self.curve1.setData(frequency, amplitude)
        self.curve2.setData(frequency, phase)

    def showPeak(self, frequency, amplitude):
        self.peakMarker.setValue(frequency, amplitude)
        label = self.peakMarker.label()
        label.setText('Peak: %4g dB' % amplitude)
        self.peakMarker.setLabel(label)

#.........这里部分代码省略.........
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:103,代码来源:BodeDemo.py

示例11: DataPlot

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
class DataPlot(QwtPlot):

    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setCanvasBackground(Qt.white)
        self.alignScales()

        # Initialize data
        self.x = np.arange(0.0, 100.1, 0.5)
        self.y = np.zeros(len(self.x), np.float)
        self.z = np.zeros(len(self.x), np.float)

        self.setTitle("A Moving QwtPlot Demonstration")
        self.insertLegend(QwtLegend(), QwtPlot.BottomLegend);

        self.curveR = QwtPlotCurve("Data Moving Right")
        self.curveR.attach(self)
        self.curveL = QwtPlotCurve("Data Moving Left")
        self.curveL.attach(self)

        self.curveL.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                        QBrush(),
                                        QPen(Qt.yellow),
                                        QSize(7, 7)))

        self.curveR.setPen(QPen(Qt.red))
        self.curveL.setPen(QPen(Qt.blue))

        mY = QwtPlotMarker()
        mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        mY.setLineStyle(QwtPlotMarker.HLine)
        mY.setYValue(0.0)
        mY.attach(self)

        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "Values")
    
        self.startTimer(50)
        self.phase = 0.0

    def alignScales(self):
        self.canvas().setFrameStyle(QFrame.Box | QFrame.Plain)
        self.canvas().setLineWidth(1)
        for i in range(QwtPlot.axisCnt):
            scaleWidget = self.axisWidget(i)
            if scaleWidget:
                scaleWidget.setMargin(0)
            scaleDraw = self.axisScaleDraw(i)
            if scaleDraw:
                scaleDraw.enableComponent(QwtAbstractScaleDraw.Backbone, False)
    
    def timerEvent(self, e):
        if self.phase > np.pi - 0.0001:
            self.phase = 0.0

        # y moves from left to right:
        # shift y array right and assign new value y[0]
        self.y = np.concatenate((self.y[:1], self.y[:-1]), 1)
        self.y[0] = np.sin(self.phase) * (-1.0 + 2.0*random.random())
		
        # z moves from right to left:
        # Shift z array left and assign new value to z[n-1].
        self.z = np.concatenate((self.z[1:], self.z[:1]), 1)
        self.z[-1] = 0.8 - (2.0 * self.phase/np.pi) + 0.4*random.random()

        self.curveR.setData(self.x, self.y)
        self.curveL.setData(self.x, self.z)

        self.replot()
        self.phase += np.pi*0.02
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:73,代码来源:DataDemo.py

示例12: MapDemo

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [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

示例13: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        # set plot title
        self.setTitle('ImagePlot')
        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # set legend
        legend = QwtLegend()
        legend.setDefaultItemMode(QwtLegendData.Clickable)
        self.insertLegend(legend, QwtPlot.RightLegend)
        # set axis titles
        self.setAxisTitle(QwtPlot.xBottom, 'time (s)')
        self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)')

        colorMap = QwtLinearColorMap(Qt.blue, Qt.red)
        interval = QwtInterval(-1, 1)
        self.enableAxis(QwtPlot.yRight)
        self.setAxisScale(QwtPlot.yRight, -1, 1)
        self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True)
        self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap)

        # 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)
        # attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        # attach a horizontal marker at y = 0
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(0.0, 0.0)
        marker.setLineStyle(QwtPlotMarker.HLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        marker.setLabel(QwtText('y = 0'))
        # attach a vertical marker at x = pi
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(np.pi, 0.0)
        marker.setLineStyle(QwtPlotMarker.VLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        marker.setLabel(QwtText('x = pi'))
        # attach a plot image
        plotImage = PlotImage('Image')
        plotImage.attach(self)
        plotImage.setData(square(512, -2*np.pi, 2*np.pi),
                          (-2*np.pi, 2*np.pi), (-2*np.pi, 2*np.pi))

        legend.SIG_CLICKED.connect(self.toggleVisibility)
        
        # replot
        self.replot()
开发者ID:petebachant,项目名称:python-qwt,代码行数:66,代码来源:ImagePlotDemo.py

示例14: __init__

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.xMap = QwtScaleMap()
        self.xMap.setScaleInterval(-0.5, 10.5)
        self.yMap = QwtScaleMap()
        self.yMap.setScaleInterval(-1.1, 1.1)

        # frame style
        self.setFrameStyle(QFrame.Box | QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        # calculate values
        self.x = np.arange(0, 10.0, 10.0/27)
        self.y = np.sin(self.x)*np.cos(2*self.x)
        
        # make curves with different styles
        self.curves = []
        self.titles = []
        # curve 1
        self.titles.append('Style: Sticks, Symbol: Ellipse')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.red))
        curve.setStyle(QwtPlotCurve.Sticks)
        curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                      QBrush(Qt.yellow),
                                      QPen(Qt.blue),
                                      QSize(5, 5)))
        self.curves.append(curve)
        # curve 2
        self.titles.append('Style: Lines, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        self.curves.append(curve)
        # curve 3
        self.titles.append('Style: Lines, Symbol: None, Antialiased')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkBlue))
        curve.setStyle(QwtPlotCurve.Lines)
        curve.setRenderHint(QwtPlotItem.RenderAntialiased)
        self.curves.append(curve)
        # curve 4
        self.titles.append('Style: Steps, Symbol: None')
        curve = QwtPlotCurve()
        curve.setPen(QPen(Qt.darkCyan))
        curve.setStyle(QwtPlotCurve.Steps)
        self.curves.append(curve)        
        # curve 5
        self.titles.append('Style: NoCurve, Symbol: XCross')
        curve = QwtPlotCurve()
        curve.setStyle(QwtPlotCurve.NoCurve)
        curve.setSymbol(QwtSymbol(QwtSymbol.XCross,
                                      QBrush(),
                                      QPen(Qt.darkMagenta),
                                      QSize(5, 5)))
        self.curves.append(curve)

        # attach data, using Numeric
        for curve in self.curves:
            curve.setData(self.x, self.y)
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:64,代码来源:CurveDemo1.py

示例15: MyWindow

# 需要导入模块: from qwt import QwtPlotCurve [as 别名]
# 或者: from qwt.QwtPlotCurve import setPen [as 别名]

#.........这里部分代码省略.........
            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 fit(self):
        """
        Fitting data in self.t, self.v with a damped oscillation model
        """
        # fitting is performed by eyemath (aka em) thanks to
        # scipy.optimize, and the error function defined by
        # the module eyemath (line 92):
        # p[0] * sin(2*pi*p[1]*x+p[2]) * exp(-p[4]*x) - p[3]
        # so the vector of parameters is:
        # amplitude, frequency, phase, DC average, damping factor.
        yfit, plsq = em.fit_dsine(self.t, self.v, mode="Hz")
        # display the fitting model
        msg="{0:4.2f}*sin(2*pi*{1:4.2f}*t+({2:3.1f}))*exp(-{4:4.2f}*t)+{3:3.1f}".format(
            *plsq
        )
        self.ui.fitEdit.setText(msg)
        # display three curves : model and model's envelopes
        t=np.array(self.t)
        f1=np.array(yfit)
        f2=plsq[0]*np.exp(-plsq[4]*t)
        f3=-1.0*f2
        average=plsq[3]*np.ones(len(t))
        red=QtGui.QColor("#ff0000")
        self.fitCurve1.setPen(red)
        self.fitCurve2.setPen(red)
        self.fitCurve3.setPen(red)
        self.fitCurve1.setData(t, f1, len(t))
        self.fitCurve2.setData(t, f2+average, len(t))
        self.fitCurve3.setData(t, f3+average, len(t))
        return
        
    def about(self):
        """
        show license stuff
        """
        with open("license.html","w") as licenseFile:
            licenseFile.write("""
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title> About ... </title>
</head>
<body>
""")
            licenseFile.write(license)
            licenseFile.write("</body></html>")
        self.aboutWidget=QtGui.QTextBrowser(self.parent())
        self.aboutWidget.resize(600,500)
        self.aboutWidget.show()
        self.aboutWidget.setOpenExternalLinks(True)
        self.aboutWidget.setSource(QtCore.QUrl("file:license.html"))
        self.aboutWidget.setWindowTitle("About oscill4.py")
        return
        
    def manual(self):
        """
        display the manual
        """
        self.manualWidget=QtGui.QTextBrowser(self.parent())
        self.manualWidget.resize(600,500)
        self.manualWidget.show()
        self.manualWidget.setOpenExternalLinks(True)
        self.manualWidget.setSource(QtCore.QUrl("file:oscill4.html"))
        self.manualWidget.setWindowTitle("User Manual of oscill4.py")
        return
        
    def notImplemented(self):
        msg=QtGui.QMessageBox(QtGui.QMessageBox.Warning,"Sorry",
                              "not yet implemented", )
        msg.exec_()
        return
开发者ID:georgesk,项目名称:course-affordable-science,代码行数:104,代码来源:oscill4.py


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