コード例 #1
0
ファイル: cartesian.py プロジェクト: 1PYTHON1/PythonQwt
 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
     QwtPlotGrid.make(self,
                      color=Qt.lightGray,
                      width=0,
                      style=Qt.DotLine,
                      z=-1)
     # 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)
     # attach a curve
     QwtPlotCurve.make(
         x,
         np.pi * np.sin(x),
         title="y = pi*sin(x)",
         linecolor=Qt.green,
         linewidth=2,
         plot=self,
         antialiased=True,
     )
     # attach another curve
     QwtPlotCurve.make(
         x,
         4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x),
         title="y = 4*pi*sin(x)*cos(x)**2",
         linecolor=Qt.blue,
         linewidth=2,
         plot=self,
         antialiased=True,
     )
     self.replot()
コード例 #2
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)