コード例 #1
0
ファイル: image.py プロジェクト: 1PYTHON1/PythonQwt
            label="x = pi",
            linestyle=QwtPlotMarker.VLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            plot=self,
        )
        # 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.clicked.connect(self.toggleVisibility)

        # replot
        self.replot()

    def toggleVisibility(self, plotItem, idx):
        """Toggle the visibility of a plot item
        """
        plotItem.setVisible(not plotItem.isVisible())
        self.replot()


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(ImagePlot, size=(600, 400))
コード例 #2
0
ファイル: vertical.py プロジェクト: igrekus/PythonQwt
    def show_layout_details(self):
        text = ("plotLayout().canvasRect():\n%r\n\n"
                "canvas().geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.yLeft):\n%r\n\n"
                "axisWidget(QwtPlot.yLeft).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.yRight):\n%r\n\n"
                "axisWidget(QwtPlot.yRight).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.xBottom):\n%r\n\n"
                "axisWidget(QwtPlot.xBottom).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.xTop):\n%r\n\n"
                "axisWidget(QwtPlot.xTop).geometry():\n%r\n\n" % (
                    self.plotLayout().canvasRect().getCoords(),
                    self.canvas().geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.yLeft).getCoords(),
                    self.axisWidget(QwtPlot.yLeft).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.yRight).getCoords(),
                    self.axisWidget(QwtPlot.yRight).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.xBottom).getCoords(),
                    self.axisWidget(QwtPlot.xBottom).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.xTop).getCoords(),
                    self.axisWidget(QwtPlot.xTop).geometry().getCoords(),
                ))
        self.marker.setLabel(
            QwtText.make(text, family="Courier New", color=Qt.blue))


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(VerticalPlot, size=(300, 650))
コード例 #3
0
        for curve in self.curves:
            self.xMap.setPaintInterval(r.left(), r.right())
            self.yMap.setPaintInterval(r.top(), r.bottom())
            painter.setRenderHint(
                QPainter.Antialiasing,
                curve.testRenderHint(QwtPlotItem.RenderAntialiased),
            )
            curve.draw(painter, self.xMap, self.yMap, r)
            self.shiftDown(r, dy)
        # draw titles
        r = self.contentsRect()
        r.setHeight(dy)
        painter.setFont(QFont("Helvetica", 8))
        painter.setPen(Qt.black)
        for title in self.titles:
            painter.drawText(
                0,
                r.top(),
                r.width(),
                painter.fontMetrics().height(),
                Qt.AlignTop | Qt.AlignHCenter,
                title,
            )
            self.shiftDown(r, dy)


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(CurveDemo1, size=(300, 600), options=False)
コード例 #4
0
ファイル: vertical.py プロジェクト: 1PYTHON1/PythonQwt
    def show_layout_details(self):
        text = ("plotLayout().canvasRect():\n%r\n\n"
                "canvas().geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.yLeft):\n%r\n\n"
                "axisWidget(QwtPlot.yLeft).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.yRight):\n%r\n\n"
                "axisWidget(QwtPlot.yRight).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.xBottom):\n%r\n\n"
                "axisWidget(QwtPlot.xBottom).geometry():\n%r\n\n"
                "plotLayout().scaleRect(QwtPlot.xTop):\n%r\n\n"
                "axisWidget(QwtPlot.xTop).geometry():\n%r\n\n" % (
                    self.plotLayout().canvasRect().getCoords(),
                    self.canvas().geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.yLeft).getCoords(),
                    self.axisWidget(QwtPlot.yLeft).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.yRight).getCoords(),
                    self.axisWidget(QwtPlot.yRight).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.xBottom).getCoords(),
                    self.axisWidget(QwtPlot.xBottom).geometry().getCoords(),
                    self.plotLayout().scaleRect(QwtPlot.xTop).getCoords(),
                    self.axisWidget(QwtPlot.xTop).geometry().getCoords(),
                ))
        self.marker.setLabel(
            QwtText.make(text, family="Courier New", color=Qt.blue))


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(VerticalPlot, size=(300, 650))
コード例 #5
0
ファイル: eventfilter.py プロジェクト: 1PYTHON1/PythonQwt
        elif scale.alignment() == QwtScaleDraw.TopScale:
            return QRect(
                sbd, scale.height() - bld - mjt, scale.width() - sbd - ebd, mjt
            )
        else:
            return QRect()


class EventFilterWindow(QMainWindow):
    def __init__(self, parent=None):
        super(EventFilterWindow, self).__init__(parent=parent)
        toolBar = QToolBar(self)
        toolBar.addAction(QWhatsThis.createAction(toolBar))
        self.addToolBar(toolBar)
        plot = Plot()
        self.setCentralWidget(plot)
        plot.setWhatsThis(
            "An useless plot to demonstrate how to use event filtering.\n\n"
            "You can click on the color bar, the scales or move the slider.\n"
            "All points can be moved using the mouse or the keyboard."
        )
        CanvasPicker(plot)
        scalePicker = ScalePicker(plot)
        scalePicker.clicked.connect(plot.insertCurve)


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(EventFilterWindow, size=(540, 400))
コード例 #6
0
        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()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(CartesianPlot, (800, 480))
コード例 #7
0
ファイル: image.py プロジェクト: igrekus/PythonQwt
            label="x = pi",
            linestyle=QwtPlotMarker.VLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            plot=self,
        )
        # 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.clicked.connect(self.toggleVisibility)

        # replot
        self.replot()

    def toggleVisibility(self, plotItem, idx):
        """Toggle the visibility of a plot item
        """
        plotItem.setVisible(not plotItem.isVisible())
        self.replot()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(ImagePlot, size=(600, 400))
コード例 #8
0
                renderer.setDiscardFlag(
                    QwtPlotRenderer.DiscardCanvasBackground)
                renderer.setDiscardFlag(QwtPlotRenderer.DiscardCanvasFrame)
                renderer.setLayoutFlag(QwtPlotRenderer.FrameWithScales)
            renderer.renderTo(self.plot, printer)

    def exportDocument(self):
        renderer = QwtPlotRenderer(self.plot)
        renderer.exportTo(self.plot, "bode")

    def showInfo(self, text=""):
        self.statusBar().showMessage(text)

    def moved(self, point):
        info = "Freq=%g, Ampl=%g, Phase=%g" % (
            self.plot.invTransform(QwtPlot.xBottom, point.x()),
            self.plot.invTransform(QwtPlot.yLeft, point.y()),
            self.plot.invTransform(QwtPlot.yRight, point.y()),
        )
        self.showInfo(info)

    def selected(self, _):
        self.showInfo()


if __name__ == "__main__":
    from qwt.tests import test_widget
    import os

    app = test_widget(BodeDemo, (640, 480))
コード例 #9
0
import numpy as np

np.seterr(all="raise")

from qtpy.QtGui import QPen
from qtpy.QtCore import Qt
from qwt import QwtPlot, QwtPlotCurve, QwtLogScaleEngine


class LogCurvePlot(QwtPlot):
    def __init__(self):
        super(LogCurvePlot,
              self).__init__("LogCurveDemo.py (or how to handle -inf values)")
        self.enableAxis(QwtPlot.xBottom)
        self.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
        x = np.arange(0.0, 10.0, 0.1)
        y = 10 * np.cos(x)**2 - 0.1
        QwtPlotCurve.make(x,
                          y,
                          linecolor=Qt.magenta,
                          plot=self,
                          antialiased=True)
        self.replot()


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(LogCurvePlot, size=(800, 500))
コード例 #10
0
        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
        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)


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(ErrorBarPlot, size=(640, 480))
コード例 #11
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()


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(MapDemo, size=(600, 600))
コード例 #12
0
        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()


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(MultiDemo, size=(400, 300))
コード例 #13
0
        self.newValues()
        self.repaint()

    def newValues(self):
        phase = self.phase

        self.xval = np.arange(0, 2.01 * np.pi, 2 * np.pi / (Size - 1))
        self.yval = np.sin(self.xval - phase)
        self.zval = np.cos(3 * (self.xval + phase))

        s = 0.25 * np.sin(phase)
        c = np.sqrt(1.0 - s * s)
        u = self.uval
        self.uval = c * self.uval - s * self.vval
        self.vval = c * self.vval + s * u

        self.tuples[0][0].setData(self.yval, self.xval)
        self.tuples[1][0].setData(self.xval, self.zval)
        self.tuples[2][0].setData(self.yval, self.zval)
        self.tuples[3][0].setData(self.uval, self.vval)

        self.phase += 2 * np.pi / 100
        if self.phase > 2 * np.pi:
            self.phase = 0.0


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(CurveDemo2, options=False)
コード例 #14
0
ファイル: bodedemo.py プロジェクト: igrekus/PythonQwt
                renderer.setDiscardFlag(QwtPlotRenderer.DiscardBackground)
                renderer.setDiscardFlag(
                    QwtPlotRenderer.DiscardCanvasBackground)
                renderer.setDiscardFlag(QwtPlotRenderer.DiscardCanvasFrame)
                renderer.setLayoutFlag(QwtPlotRenderer.FrameWithScales)
            renderer.renderTo(self.plot, printer)

    def exportDocument(self):
        renderer = QwtPlotRenderer(self.plot)
        renderer.exportTo(self.plot, "bode")

    def showInfo(self, text=""):
        self.statusBar().showMessage(text)

    def moved(self, point):
        info = "Freq=%g, Ampl=%g, Phase=%g" % (
            self.plot.invTransform(QwtPlot.xBottom, point.x()),
            self.plot.invTransform(QwtPlot.yLeft, point.y()),
            self.plot.invTransform(QwtPlot.yRight, point.y()),
        )
        self.showInfo(info)

    def selected(self, _):
        self.showInfo()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(BodeDemo, (640, 480))
コード例 #15
0
ファイル: simple.py プロジェクト: igrekus/PythonQwt
        # insert a few curves
        x = np.arange(0.0, 10.0, 0.1)
        qwt.QwtPlotCurve.make(x, np.sin(x), "y = sin(x)", self, linecolor="red")
        qwt.QwtPlotCurve.make(x, np.cos(x), "y = cos(x)", self, linecolor="blue")

        # insert a horizontal marker at y = 0
        qwt.QwtPlotMarker.make(
            label="y = 0",
            align=Qt.AlignRight | Qt.AlignTop,
            linestyle=qwt.QwtPlotMarker.HLine,
            color="darkGreen",
            plot=self,
        )

        # insert a vertical marker at x = 2 pi
        qwt.QwtPlotMarker.make(
            xvalue=2 * np.pi,
            label="x = 2 pi",
            align=Qt.AlignRight | Qt.AlignTop,
            linestyle=qwt.QwtPlotMarker.VLine,
            color="darkGreen",
            plot=self,
        )


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(SimplePlot, size=(600, 400))
コード例 #16
0
        # 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)


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(ErrorBarPlot, size=(640, 480))
コード例 #17
0
        self.newValues()
        self.repaint()

    def newValues(self):
        phase = self.phase

        self.xval = np.arange(0, 2.01 * np.pi, 2 * np.pi / (Size - 1))
        self.yval = np.sin(self.xval - phase)
        self.zval = np.cos(3 * (self.xval + phase))

        s = 0.25 * np.sin(phase)
        c = np.sqrt(1.0 - s * s)
        u = self.uval
        self.uval = c * self.uval - s * self.vval
        self.vval = c * self.vval + s * u

        self.tuples[0][0].setData(self.yval, self.xval)
        self.tuples[1][0].setData(self.xval, self.zval)
        self.tuples[2][0].setData(self.yval, self.zval)
        self.tuples[3][0].setData(self.uval, self.vval)

        self.phase += 2 * np.pi / 100
        if self.phase > 2 * np.pi:
            self.phase = 0.0


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(CurveDemo2, options=False)
コード例 #18
0
ファイル: logcurve.py プロジェクト: igrekus/PythonQwt
SHOW = True  # Show test in GUI-based test launcher

import numpy as np

np.seterr(all="raise")

from qtpy.QtCore import Qt
from qwt import QwtPlot, QwtPlotCurve, QwtLogScaleEngine


class LogCurvePlot(QwtPlot):
    def __init__(self):
        super(LogCurvePlot,
              self).__init__("LogCurveDemo.py (or how to handle -inf values)")
        self.enableAxis(QwtPlot.xBottom)
        self.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
        x = np.arange(0.0, 10.0, 0.1)
        y = 10 * np.cos(x)**2 - 0.1
        QwtPlotCurve.make(x,
                          y,
                          linecolor=Qt.magenta,
                          plot=self,
                          antialiased=True)
        self.replot()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(LogCurvePlot, size=(800, 500))
コード例 #19
0
class LoadTest(cb.CurveBenchmark1):
    TITLE = "Load test [%d plots]" % NPLOTS
    SIZE = (1600, 700)

    def __init__(self, max_n=100, parent=None, unattended=False, **kwargs):
        super(LoadTest, self).__init__(max_n=max_n,
                                       parent=parent,
                                       unattended=unattended,
                                       **kwargs)

    def run_benchmark(self, max_n, **kwargs):
        points, symbols = 100, False
        for _i_page in range(int(NPLOTS / (NCOLS * NROWS))):
            t0 = time.time()
            symtext = "with%s symbols" % ("" if symbols else "out")
            widget = LTWidget(NCOLS, points, symbols, **kwargs)
            title = "%d points" % points
            description = "%d plots with %d curves of %d points, %s" % (
                widget.plot_nb,
                widget.curve_nb,
                points,
                symtext,
            )
            self.process_iteration(title, description, widget, t0)


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(LoadTest, options=False)
コード例 #20
0
ファイル: multidemo.py プロジェクト: igrekus/PythonQwt
        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()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(MultiDemo, size=(400, 300))
コード例 #21
0
ファイル: cpudemo.py プロジェクト: 1PYTHON1/PythonQwt
        self.replot()

    def showCurve(self, item, on, index=None):
        item.setVisible(on)
        self.legend().legendWidget(item).setChecked(on)
        self.replot()

    def cpuPlotCurve(self, key):
        return self.curves[key]


class CpuDemo(QWidget):
    def __init__(self, parent=None):
        super(CpuDemo, self).__init__(parent)
        layout = QVBoxLayout()
        self.setLayout(layout)
        plot = CpuPlot()
        plot.setTitle("History")
        layout.addWidget(plot)
        label = QLabel("Press the legend to en/disable a curve")
        layout.addWidget(label)


if __name__ == "__main__":
    from qwt.tests import test_widget

    if os.environ.get("TEST_UNATTENDED") is not None:
        SHOW_ALL_CURVES = True
        TIMER_INTERVAL = 20
    app = test_widget(CpuDemo, (600, 400))
コード例 #22
0
ファイル: data.py プロジェクト: igrekus/PythonQwt
                scaleWidget.setMargin(0)
            scaleDraw = self.axisScaleDraw(axis_id)
            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]))
        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]))
        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


if __name__ == "__main__":
    from qwt import tests

    app = tests.test_widget(DataPlot, size=(500, 300))
コード例 #23
0
        qwt.QwtPlotCurve.make(x,
                              np.cos(x),
                              "y = cos(x)",
                              self,
                              linecolor="blue")

        # insert a horizontal marker at y = 0
        qwt.QwtPlotMarker.make(
            label="y = 0",
            align=Qt.AlignRight | Qt.AlignTop,
            linestyle=qwt.QwtPlotMarker.HLine,
            color="darkGreen",
            plot=self,
        )

        # insert a vertical marker at x = 2 pi
        qwt.QwtPlotMarker.make(
            xvalue=2 * np.pi,
            label="x = 2 pi",
            align=Qt.AlignRight | Qt.AlignTop,
            linestyle=qwt.QwtPlotMarker.VLine,
            color="darkGreen",
            plot=self,
        )


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(SimplePlot, size=(600, 400))
コード例 #24
0
class CurveBenchmark2(cb.CurveBenchmark1):
    TITLE = "Curve styles"
    SIZE = (1000, 800)

    def __init__(self, max_n=1000, parent=None, **kwargs):
        super(CurveBenchmark2, self).__init__(max_n=max_n,
                                              parent=parent,
                                              **kwargs)

    def run_benchmark(self, max_n, **kwargs):
        for points, symbols in zip((max_n / 10, max_n / 10, max_n, max_n),
                                   (True, False) * 2):
            t0 = time.time()
            symtext = "with%s symbols" % ("" if symbols else "out")
            widget = CSWidget(points, symbols, **kwargs)
            title = "%d points" % points
            description = "%d plots with %d curves of %d points, %s" % (
                widget.plot_nb,
                widget.curve_nb,
                points,
                symtext,
            )
            self.process_iteration(title, description, widget, t0)


if __name__ == "__main__":
    from qwt.tests import test_widget

    app = test_widget(CurveBenchmark2, options=False)
コード例 #25
0
        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()


if __name__ == "__main__":
    from qwt import tests

    tests.test_widget(MapDemo, size=(600, 600))