Esempio n. 1
0
    def __init__(self):
        super().__init__()
        self.setAutoFillBackground(True)
        self.setPalette(QPalette(QColor(165, 193, 228)))
        self.updateGradient()
        self.setTitle("A Simple QwtPlot Demonstration")
        self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend)

        #axes
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "x -->")
        self.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 10.0)

        self.setAxisTitle(Qwt.QwtPlot.yLeft, "y -->")
        self.setAxisScale(Qwt.QwtPlot.yLeft, -1.0, 1.0)
        # canvas
        self.canvas = Qwt.QwtPlotCanvas()
        self.canvas.setLineWidth(1)
        self.canvas.setFrameStyle(QFrame.Box | QFrame.Plain)
        self.canvas.setBorderRadius(15)

        self.canvasPalette = QPalette(Qt.white)
        self.canvasPalette.setColor(QPalette.Foreground, QColor(133, 190, 232))
        self.canvas.setPalette(self.canvasPalette)

        self.setCanvas(self.canvas)

        #panning with the left mouse button
        self.panner = Qwt.QwtPlotPanner(self.canvas)

        #zoom in/out with the wheel
        self.magnifier = Qwt.QwtPlotMagnifier(self.canvas)
        self.magnifier.setMouseButton(Qt.NoButton)

        self.populate()
Esempio n. 2
0
    def __init__(self, parent=None):
        Qwt.QwtPlot.__init__(self, parent)
        self.setTitle("Watching TV during a weekend")
        canvas = Qwt.QwtPlotCanvas()
        canvas.setPalette(QPalette(Qt.gray))
        canvas.setBorderRadius(10)
        self.setCanvas(canvas)

        self.plotLayout().setAlignCanvasToScales(True)

        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Number of People")
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Number of Hours")

        legend = Qwt.QwtLegend()
        legend.setDefaultItemMode(Qwt.QwtLegendData.Checkable)
        self.insertLegend(legend, Qwt.QwtPlot.RightLegend)
        self.populate()

        #connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ), SLOT( showItem( const QVariant &, bool ) ) );
        legend.checked['QVariant', 'bool', 'int'].connect(self.showItem)

        self.replot()  # creating the legend items
        self.items = self.itemList(Qwt.QwtPlotItem.Rtti_PlotHistogram)
        for i in range(len(self.items)):
            if (i == 0):
                #const QVariant
                itemInfo = self.itemToInfo(self.items[i])
                #QwtLegendLabel *
                legendLabel = legend.legendWidget(itemInfo)
                if (legendLabel):
                    legendLabel.setChecked(True)
                self.items[i].setVisible(True)
            else:
                self.items[i].setVisible(False)
        self.setAutoReplot(True)
Esempio n. 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)