示例#1
0
 def __init__(self):
     QFrame.__init__(self)
     self.d_curves = [None] * CurvCnt
     xMap.setScaleInterval(-0.5, 10.5)
     yMap.setScaleInterval(-1.1, 1.1)
     # Frame style FIXME This doesn't seem to work properly
     self.setFrameStyle(QFrame.Box | QFrame.Raised)
     self.setLineWidth(2)
     self.setMidLineWidth(3)
     # Calculate values
     for i in range(Size):
         xval[i] = i * 10.0 / (Size - 1.0)
         yval[i] = math.sin(xval[i]) * math.cos(2.0 * xval[i])
     #  define curve styles
     i = 0
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.Cross, QBrush(Qt.NoBrush),
                       QPen(Qt.black), QSize(5, 5)))
     self.d_curves[i].setPen(Qt.darkGreen)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     self.d_curves[i].setCurveAttribute(Qwt.QwtPlotCurve.Fitted)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.yellow, QPen(Qt.blue),
                       QSize(5, 5)))
     self.d_curves[i].setPen(Qt.red)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Sticks)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkBlue)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkBlue)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     self.d_curves[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkCyan)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Steps)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, QBrush(Qt.NoBrush),
                       QPen(Qt.darkMagenta), QSize(5, 5)))
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.NoCurve)
     # attach data
     for i in range(CurvCnt):
         self.d_curves[i].setSamples(xval, yval)
    def update(self, layer, style):
        """Update plot for given Safecast layer.

        :param layer: Safecast layer
        """
        # collect plot coordinates
        x, y = layer.plotData()

        # clear plot first & detach curve
        if hasQwt6:
            items = Qwt.QwtPlotItem.Rtti_PlotItem
        else:
            items = [Qwt.QwtPlotItem.Rtti_PlotItem]
        self.detachItems(items, True)

        # attach a curve
        self.curve = Qwt.QwtPlotCurve('ader_microSvh')
        self.curve.attach(self)

        if style == 0:  # lines
            self.curve.setPen(Qt.QPen(Qt.Qt.blue, 0))
        else:  # points
            self.curve.setStyle(Qwt.QwtPlotCurve.NoCurve)
            self.curve.setSymbol(
                Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.blue),
                              Qt.QPen(Qt.Qt.blue), Qt.QSize(5, 5)))

        self.curve.setSamples(x, y)

        self.replot()
示例#3
0
    def __init__(self, parent=None):
        Qwt.QwtPlot.__init__(self, parent)
        self.setAutoReplot(False)
        self.setTitle("Frequency Response of a Second-Order System")
        canvas = Qwt.QwtPlotCanvas()
        canvas.setBorderRadius(10)
        self.setCanvas(canvas)
        self.setCanvasBackground(QColor("MidnightBlue"))
        # legend
        legend = Qwt.QwtLegend()
        self.insertLegend(legend, Qwt.QwtPlot.BottomLegend)

        # grid
        grid = Qwt.QwtPlotGrid()
        grid.enableXMin(True)
        grid.setMajorPen(Qt.white, 0, Qt.DotLine)
        grid.setMinorPen(Qt.gray, 0, Qt.DotLine)
        grid.attach(self)

        # axes
        self.enableAxis(Qwt.QwtPlot.yRight)
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Normalized Frequency")
        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude [dB]")
        self.setAxisTitle(Qwt.QwtPlot.yRight, "Phase [deg]")

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

        # curves
        self.d_curve1 = Qwt.QwtPlotCurve("Amplitude")
        self.d_curve1.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        self.d_curve1.setPen(Qt.yellow)
        self.d_curve1.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine)
        self.d_curve1.setYAxis(Qwt.QwtPlot.yLeft)
        self.d_curve1.attach(self)

        self.d_curve2 = Qwt.QwtPlotCurve("Phase")
        self.d_curve2.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        self.d_curve2.setPen(Qt.cyan)
        self.d_curve2.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine)
        self.d_curve2.setYAxis(Qwt.QwtPlot.yRight)
        self.d_curve2.attach(self)

        # marker
        self.d_marker1 = Qwt.QwtPlotMarker()
        self.d_marker1.setValue(0.0, 0.0)
        self.d_marker1.setLineStyle(Qwt.QwtPlotMarker.VLine)
        self.d_marker1.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        self.d_marker1.setLinePen(Qt.green, 0, Qt.DashDotLine)
        self.d_marker1.attach(self)

        self.d_marker2 = Qwt.QwtPlotMarker()
        self.d_marker2.setLineStyle(Qwt.QwtPlotMarker.HLine)
        self.d_marker2.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        self.d_marker2.setLinePen(QColor(200, 150, 0), 0, Qt.DashDotLine)
        self.d_marker2.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Diamond, QColor(Qt.yellow),
                          QColor(Qt.green), QSize(8, 8)))
        self.d_marker2.attach(self)

        self.setDamp(0)

        self.setAutoReplot(True)
示例#4
0
a = QApplication(sys.argv)

plot=Qwt.QwtPlot()
plot.setTitle("Plot Demo")
plot.setCanvasBackground(Qt.white)
plot.insertLegend( Qwt.QwtLegend() )
grid = Qwt.QwtPlotGrid()
grid.attach( plot )

curve = Qwt.QwtPlotCurve()
curve.setTitle("Some Points")
curve.setPen(Qt.blue,4)
curve.setRenderHint( Qwt.QwtPlotItem.RenderAntialiased, True );

symbol = Qwt.QwtSymbol( Qwt.QwtSymbol.Ellipse, QBrush( Qt.yellow ), QPen( Qt.red, 2 ), QSize( 8, 8 ) );
curve.setSymbol( symbol )

x=np.arange(0,10,0.1)
y=np.sin(x)
curve.setSamples(x,y)
curve.attach(plot)

zoomer = Qwt.QwtPlotZoomer( Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, plot.canvas() );
zoomer.setZoomBase(False);
zoomer.zoom(0);

plot.resize(600,400)
plot.replot()
plot.show()
sys.exit(a.exec_())