コード例 #1
0
    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)
コード例 #2
0
ファイル: CurveDemo2.py プロジェクト: qinghhua/plotpy
    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)
コード例 #3
0
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = np.arange(0, 10.1, 0.5, np.float)
    y = np.sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2  # all error bars the same size
    errorOnTop = False  # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x=x,
        y=y,
        dx=dx,
        dy=dy,
        curvePen=QPen(Qt.black, 2),
        curveSymbol=QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red),
                              QPen(Qt.black, 2), QSize(9, 9)),
        errorPen=QPen(Qt.blue, 2),
        errorCap=10,
        errorOnTop=errorOnTop,
    )
    curve.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
コード例 #4
0
 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()
コード例 #5
0
    def __init__(self, parent=None, title=None):
        super(ErrorBarPlot, self).__init__("Errorbar Demonstation")
        self.setCanvasBackground(Qt.white)
        self.plotLayout().setAlignCanvasToScales(True)
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

        # calculate data and errors for a curve with error bars
        x = np.arange(0, 10.1, 0.5, float)
        y = np.sin(x)
        dy = 0.2 * abs(y)
        # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
        dx = 0.2  # all error bars the same size
        errorOnTop = False  # uncomment to draw the curve on top of the error bars
        # errorOnTop = True # uncomment to draw the error bars on top of the curve
        symbol = QwtSymbol(
            QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.black, 2), QSize(9, 9)
        )
        curve = ErrorBarPlotCurve(
            x=x,
            y=y,
            dx=dx,
            dy=dy,
            curvePen=QPen(Qt.black, 2),
            curveSymbol=symbol,
            errorPen=QPen(Qt.blue, 2),
            errorCap=10,
            errorOnTop=errorOnTop,
        )
        curve.attach(self)
コード例 #6
0
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Curve Demonstation"))
    #   demo.setCanvasBackground(Qt.white)
    #   demo.plotLayout().setAlignCanvasToScales(True)

    #   grid = QwtPlotGrid()
    #   grid.attach(demo)
    #   grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = numpy.zeros(20, numpy.float32)
    y = numpy.zeros(20, numpy.float32)
    symbol_sizes = numpy.zeros(20, numpy.int32)
    symbolList = []
    for i in range(20):
        x[i] = 1.0 * i
        y[i] = 2.0 * i
        symbol_sizes[i] = 3 + i
        if i % 2 == 0:
            symbolList.append(
                QwtSymbol(QwtSymbol.UTriangle, QBrush(Qt.black),
                          QPen(Qt.black), QSize(3 + i, 3 + i)))
        else:
            symbolList.append(
                QwtSymbol(QwtSymbol.DTriangle, QBrush(Qt.red), QPen(Qt.red),
                          QSize(3 + i, 3 + i)))

    curve = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes)
    x = x + 10
    curve1 = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes)
    curve.setSymbol(
        QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.black), QPen(Qt.black),
                  QSize(5, 5)))
    curve.setPen(QPen(Qt.blue, 2))
    curve1.setSymbol(
        QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.red),
                  QSize(10, 10)))
    curve1.setPen(QPen(Qt.blue, 2))
    curve1.setSymbolList(symbolList)

    curve.attach(demo)
    curve1.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
コード例 #7
0
    def __init__(
        self,
        x=[],
        y=[],
        dx=None,
        dy=None,
        curvePen=None,
        curveStyle=None,
        curveSymbol=None,
        errorPen=None,
        errorCap=0,
        errorOnTop=False,
    ):
        """A curve of x versus y data with error bars in dx and dy.

        Horizontal error bars are plotted if dx is not None.
        Vertical error bars are plotted if dy is not None.

        x and y must be sequences with a shape (N,) and dx and dy must be
        sequences (if not None) with a shape (), (N,), or (2, N):
        - if dx or dy has a shape () or (N,), the error bars are given by
          (x-dx, x+dx) or (y-dy, y+dy),
        - if dx or dy has a shape (2, N), the error bars are given by
          (x-dx[0], x+dx[1]) or (y-dy[0], y+dy[1]).

        curvePen is the pen used to plot the curve

        curveStyle is the style used to plot the curve

        curveSymbol is the symbol used to plot the symbols

        errorPen is the pen used to plot the error bars

        errorCap is the size of the error bar caps

        errorOnTop is a boolean:
        - if True, plot the error bars on top of the curve,
        - if False, plot the curve on top of the error bars.
        """

        QwtPlotCurve.__init__(self)

        if curvePen is None:
            curvePen = QPen(Qt.NoPen)
        if curveStyle is None:
            curveStyle = QwtPlotCurve.Lines
        if curveSymbol is None:
            curveSymbol = QwtSymbol()
        if errorPen is None:
            errorPen = QPen(Qt.NoPen)

        self.setData(x, y, dx, dy)
        self.setPen(curvePen)
        self.setStyle(curveStyle)
        self.setSymbol(curveSymbol)
        self.errorPen = errorPen
        self.errorCap = errorCap
        self.errorOnTop = errorOnTop
コード例 #8
0
 def params(self, *args):
     symbols, = args
     symb1 = QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.yellow), QPen(Qt.blue),
                       QSize(5, 5))
     symb2 = QwtSymbol(QwtSymbol.XCross, QBrush(), QPen(Qt.darkMagenta),
                       QSize(5, 5))
     if symbols:
         return (
             ('Sticks', symb1),
             ('Lines', symb1),
             ('Steps', symb2),
             ('Dots', symb2),
         )
     else:
         return (
             ('Sticks', None),
             ('Lines', None),
             ('Steps', None),
             ('Dots', None),
         )
コード例 #9
0
ファイル: eventfilter.py プロジェクト: 1PYTHON1/PythonQwt
 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)
コード例 #10
0
    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
コード例 #11
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.uut_dev = None
        self.timerId = None
        #self.interval = 250    # ms
        self.interval = config.interval  # ms

        fileTIME = datetime.datetime.now()
        File_timestamp = "%04d-%02d-%02d_%02d%02d%02d" % (
            fileTIME.year, fileTIME.month, fileTIME.day, fileTIME.hour,
            fileTIME.minute, fileTIME.second)

        self.fileNamme = '.\data\data_%s.txt' % File_timestamp
        print('Raw data record file name:%s' % self.fileNamme)
        # default parameters from config file
        self.x_ZERO = config.X_lower
        self.x_range = config.X_upper
        self.x_interval = config.X_grid_interval
        self.y_range_Upper = config.Y_upper
        self.y_range_Lower = config.Y_lower
        self.y_interval = config.Y_grid_interval
        self.unit = 'kPa'  # default value, will replaced by actual reading.
        #self.getReadingCommand = r"UPPER_VAL?\r\n"  # default pass and pac
        #self.getResp_rex = r'^[-]?([0-9]{1,}[.]?[0-9]*)'

        self.lenth = config.Slope_lenth  #  40 = 10s caculate the slowrate

        # QwtPlot property
        # Initialize 坐标轴
        self.setCanvasBackground(Qt.white)  #Qt.white
        self.alignScales()
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine))

        # x Axis property
        #self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw(self.cpuStat.upTime()))
        #timeScale = QwtDateScaleDraw(Qt.LocalTime)
        #print(timeScale)
        #self.setAxisScaleDraw(QwtPlot.xBottom, timeScale)

        self.setAxisScale(QwtPlot.xBottom, 0.0, self.x_range, self.x_interval)

        #self.setAxisAutoScale(QwtPlot.yLeft,True)
        #self.setAxisScale(QwtPlot.yLeft,99.99,100.0,0.0005)
        self.setAxisScale(QwtPlot.yLeft, self.y_range_Lower,
                          self.y_range_Upper, self.y_interval)
        self.setAxisLabelRotation(QwtPlot.xBottom, -45.0)

        self.x = np.arange(
            0.0, self.x_range + 1, 0.25
        )  #0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms

        #self.z = np.zeros(len(self.x), np.float)
        list = []
        for i in range(len(self.x)):
            list.append(0.0)
        self.z = np.array(list)

        rlist = []

        for i in range(self.lenth):  # 10s
            rlist.append(0.0)
        self.RateList = np.array(rlist)

        self.setTitle("UUT Reading Monitor - OutPort(%s)\r\n" % (self.unit))
        #self.insertLegend(QwtLegend(), QwtPlot.RightLegend);

        self.curveL = QwtPlotCurve("UUT Reading")
        self.curveL.attach(self)
        pen = QPen(Qt.red)
        pen.setWidth(1.5)
        #pen.setWidth(1)
        self.curveL.setPen(pen)

        font = QFont()
        font.setFamily("Calibri")  #,Consolas
        font.setPointSize(16)

        # show the latest reading. line and point value
        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignLeft | Qt.AlignTop)
        m.setLinePen(QPen(Qt.blue, 1.5, Qt.DashDotLine))

        text = QwtText('Reading: ----')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))

        text.setFont(font)

        m.setLabel(text)
        # MarkPoint symbol
        m.setSymbol(
            QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.blue), QPen(Qt.green),
                      QSize(7, 7)))
        m.attach(self)

        # text marker  , display slope rate
        self.txtMarker = m = QwtPlotMarker()
        m.setValue(self.x_range / 2,
                   self.y_range_Upper - self.y_interval / 2)  # show position
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText('Slope Rate: ----')
        text.setFont(font)
        text.setColor(Qt.white)
        text.setBackgroundBrush(QBrush(Qt.black))
        text.setBorderPen(QPen(Qt.red, 2))

        m.setLabel(text)
        m.attach(self)

        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading(%s)" % (self.unit))

        self.replot()

        #self.startTimer(250)#ms# FOR GET READING
        #self.starttime = time.clock();#unit: s    python2
        self.starttime = time.time()  # python3

        self.idx = 0
        self.readfmt = "%f"
        self.Saveinfo("Starting...")
コード例 #12
0
    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
        QwtPlotGrid.make(plot=self,
                         enableminor=(True, False),
                         color=Qt.darkGray)

        # 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.make(title="Amplitude",
                                        linecolor=Qt.yellow,
                                        plot=self,
                                        antialiased=True)
        self.curve2 = QwtPlotCurve.make(title="Phase",
                                        linecolor=Qt.cyan,
                                        plot=self,
                                        antialiased=True)
        self.dB3Marker = QwtPlotMarker.make(
            label=QwtText.make(color=Qt.white,
                               brush=Qt.red,
                               weight=QFont.Light),
            linestyle=QwtPlotMarker.VLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            color=Qt.green,
            width=2,
            style=Qt.DashDotLine,
            plot=self,
        )
        self.peakMarker = QwtPlotMarker.make(
            label=QwtText.make(color=Qt.red,
                               brush=self.canvasBackground(),
                               weight=QFont.Bold),
            symbol=QwtSymbol.make(QwtSymbol.Diamond, Qt.yellow, Qt.green,
                                  (7, 7)),
            linestyle=QwtPlotMarker.HLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            color=Qt.red,
            width=2,
            style=Qt.DashDotLine,
            plot=self,
        )
        QwtPlotMarker.make(
            xvalue=0.1,
            yvalue=-20.0,
            align=Qt.AlignRight | Qt.AlignBottom,
            label=QwtText.make(
                "[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]"
                "<sup>-1</sup>",
                color=Qt.white,
                borderradius=2,
                borderpen=QPen(Qt.lightGray, 5),
                brush=Qt.lightGray,
                weight=QFont.Bold,
            ),
            plot=self,
        )

        self.setDamp(0.01)
コード例 #13
0
ファイル: BodeDemo.py プロジェクト: qinghhua/plotpy
    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)
コード例 #14
0
path = QPainterPath()
path.moveTo(0, 8)
path.lineTo(0, 5)
path.lineTo(-3, 5)
path.lineTo(0, 0)
path.lineTo(3, 5)
path.lineTo(0, 5)

transform = QTransform()
transform.rotate(-30.0)
path = transform.map(path)

pen = QPen(Qt.black, 2)
pen.setJoinStyle(Qt.MiterJoin)

symbol = QwtSymbol()
symbol.setPen(pen)
symbol.setBrush(Qt.red)
symbol.setPath(path)
symbol.setPinPoint(QPointF(0.0, 0.0))
symbol.setSize(10, 14)

# --- Test it within a simple plot ---

curve = QwtPlotCurve()
curve_pen = QPen(Qt.blue)
curve_pen.setStyle(Qt.DotLine)
curve.setPen(curve_pen)
curve.setSymbol(symbol)
x = np.linspace(0, 10, 10)
curve.setData(x, np.sin(x))
コード例 #15
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        
        self.uut_dev = None
        self.timerId = None
        self.interval = 250    # ms
        
        
        fileTIME = datetime.datetime.now()
        File_timestamp = "%04d-%02d-%02d_%02d%02d%02d" % (fileTIME.year,fileTIME.month,fileTIME.day,fileTIME.hour, fileTIME.minute, fileTIME.second)

        self.fileNamme = '.\data\data_%s.txt'%File_timestamp
        print(self.fileNamme)
        self.x_range = 180.1
        self.x_interval = 10.0
        self.y_range_Upper = 210.0
        self.y_range_Lower = -90.0
        self.y_interval = 20.0
        self.unit = 'kPa'  # default value, will replaced by actual reading.
        self.getReadingCommand = r"UPPER_VAL?\r\n"  # default pass and pac
        self.getResp_rex = r'^[-]?([0-9]{1,}[.]?[0-9]*)'
                              
        self.lenth = 40 # 10s caculate the slowrate
                
        # QwtPlot property
        # Initialize 坐标轴
        self.setCanvasBackground(Qt.white)  #Qt.white
        self.alignScales()
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine))
        
        self.setAxisScale(QwtPlot.xBottom, 0.0,self.x_range,self.x_interval)
        #self.setAxisAutoScale(QwtPlot.yLeft,True)
        #self.setAxisScale(QwtPlot.yLeft,99.99,100.0,0.0005)
        self.setAxisScale(QwtPlot.yLeft,self.y_range_Lower,self.y_range_Upper,self.y_interval)
        self.setAxisLabelRotation(QwtPlot.xBottom,-45.0)
        
        self.x = np.arange(0.0, self.x_range + 1, 0.25)#0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms

        #self.z = np.zeros(len(self.x), np.float)
        
        list = []
        for i in range(len(self.x)):
            list.append(0.0)
        self.z = np.array(list)  
       
        rlist = []
        
        for i in range(self.lenth):  # 10s
            rlist.append(0.0)       
        self.RateList = np.array(rlist)           

        self.setTitle("UUT Reading Monitor - OutPort(%s)\r\n"%(self.unit))
        self.insertLegend(QwtLegend(), QwtPlot.RightLegend);

        
        self.curveL = QwtPlotCurve("UUT Reading")
        self.curveL.attach(self)
        pen = QPen(Qt.red)
        pen.setWidth(1.5)
        self.curveL.setPen(pen)
        
        # show peak line and point value
        fn = self.fontInfo().family()
        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignLeft | Qt.AlignTop)
        m.setLinePen(QPen(Qt.blue, 1.5, Qt.DashDotLine))
        
        text = QwtText('dfdfdfdf')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))
        text.setFont(QFont(fn, 12, QFont.Bold))         
        m.setLabel(text)
        # MarkPoint symbol
        m.setSymbol(QwtSymbol(QwtSymbol.Diamond,
                              QBrush(Qt.blue),
                              QPen(Qt.green),
                              QSize(7,7)))
        m.attach(self)
        
        # text marker
        self.txtMarker = m = QwtPlotMarker()
        m.setValue(self.x_range/2, self.y_range_Upper - self.y_interval/2)   # show position
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText('initial')
        text.setFont(QFont(fn, 20, QFont.Bold))
        text.setColor(Qt.white)
        text.setBackgroundBrush(QBrush(Qt.black))
        text.setBorderPen(QPen(Qt.red, 2))

        m.setLabel(text)
        m.attach(self)
        

        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading(%s)"%(self.unit))
        self.replot()
 
        #self.startTimer(250)#ms# FOR GET READING
        
        self.starttime = time.clock();#unit: s
        self.idx = 0
        self.readfmt = "%f" 
        self.Saveinfo("Starting...")