Пример #1
0
 def __init__(self, *args):
     QwtPlot.__init__(self, *args)
     global x, y, lineL, lineH, curveTemp
     HISTORY = 300
     x = 0.1 * np.arange(0, -HISTORY, -1)
     y = np.zeros(HISTORY, np.float)
     self.setAxisScale(QwtPlot.yLeft, 0, 100)
     lineL = QwtPlotMarker()
     lineL.setLinePen(QtGui.QPen(QtCore.Qt.blue))
     lineL.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom)
     lineL.setLineStyle(QwtPlotMarker.HLine)
     lineL.setYValue(0)
     lineL.attach(self)
     lineH = QwtPlotMarker()
     lineH.setLinePen(QtGui.QPen(QtCore.Qt.red))
     lineH.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
     lineH.setLineStyle(QwtPlotMarker.HLine)
     lineH.setYValue(100)
     lineH.attach(self)
     curveTemp = QwtPlotCurve("实时温度")
     curveTemp.attach(self)
Пример #2
0
def main(args):
    app = QApplication(args)
    demo = QwtPlot()
    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
    grid.enableX(True)
    grid.enableY(True)
    complex_divider = 50.0

    myXScale = ComplexScaleDraw(start_value=0.0, end_value=complex_divider)
    #print('myXScale', myXScale)
    demo.setAxisScaleDraw(QwtPlot.xBottom, myXScale)

    m = QwtPlotMarker()
    m.attach(demo)
    m.setValue(complex_divider, 0.0)
    m.setLineStyle(QwtPlotMarker.VLine)
    m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
    m.setLinePen(QPen(Qt.black, 2, Qt.SolidLine))

    vector_array = numpy.zeros((100, ), numpy.float32)
    for i in range(100):
        vector_array[i] = i

    curve = QwtPlotCurve('example data')
    curve.attach(demo)
    x_array = numpy.zeros(100, numpy.float32)
    y_array = numpy.zeros(100, numpy.float32)
    for i in range(100):
        x_array[i] = 1.0 * i
        y_array[i] = 2.0 * i
    curve.setSamples(x_array, y_array)

    demo.resize(600, 400)
    demo.replot()
    demo.show()
    #   app.setMainWidget(demo)
    app.exec_()