Beispiel #1
0
    def create_plot(self):
        """
        Purpose:   create the pythonqwt plot
        Return:    return a list containing the plot and the list of the curves
        """
        plot = Qwt.QwtPlot(self)
        plot.setCanvasBackground(Qt.black)

        plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time')
        plot.setAxisScale(Qwt.QwtPlot.xBottom, 0, 10, 1)

        plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Temperature')
        plot.setAxisScale(Qwt.QwtPlot.yLeft, LeftYMIN, LeftYMAX,
                          (LeftYMAX - LeftYMIN) / 5)

        plot.setAxisTitle(Qwt.QwtPlot.yRight, 'Humidity')
        plot.setAxisScale(Qwt.QwtPlot.yRight, RightYMIN, RightYMAX,
                          (RightYMAX - RightYMIN) / 5)
        plot.replot()

        curve = [None] * 3
        pen = [
            QPen(QColor('red')),
            QPen(QColor('green')),
            QPen(QColor('blue'))
        ]

        for i in range(3):
            curve[i] = Qwt.QwtPlotCurve('')
            curve[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
            pen[i].setWidth(2)
            curve[i].setPen(pen[i])
            curve[i].attach(plot)

        return plot, curve
    def create_plot(self):
        """
        Purpose:   create the pyqwt plot
        Return:    return a list containing the plot and the list of the curves
        """
        plot = Qwt.QwtPlot(self)
        plot.setCanvasBackground(Qt.black)
        plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time [s]')
        plot.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100, 5)
        plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Concentration [ppm]')
        plot.setAxisScale(Qwt.QwtPlot.yLeft, YMIN, YMAX, (YMAX-YMIN)/10)
        plot.replot()

        curve = [None]*3
        pen = [QPen(QColor('limegreen')), QPen(QColor('red')) ,QPen(QColor('blue')) ]
        for i in range(3):
            curve[i] =  Qwt.QwtPlotCurve('')
            curve[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
            pen[i].setWidth(2)
            curve[i].setPen(pen[i])
            curve[i].attach(plot)

        return plot, curve
    #---------------------------------------------------


#    def create_knob(self):
        """
Beispiel #3
0
 def __init__(self, *args):
     Qwt.QwtPlot.__init__(self, *args)
     self.setCanvasBackground(Qt.Qt.black)
     self.x = range(0,400)
     self.y = numpy.zeros(len(self.x))
     self.curves = (Qwt.QwtPlotCurve(),Qwt.QwtPlotCurve())
     for n in (0,1):
         pen = QPen()
         pen.setWidth(3)
         pen.setColor(QColor(255-127*n,0,0))
         self.curves[n].setPen(pen)
         self.curves[n].attach(self)
     self.enableAxis(Qwt.QwtPlot.yLeft,False)
     self.enableAxis(Qwt.QwtPlot.xBottom,False)
     self.setAxisScale(Qwt.QwtPlot.yLeft,0,127)
     self.setAxisScale(Qwt.QwtPlot.xBottom,0,400)
     self.i = 0
Beispiel #4
0
 def attachCurve(self, x, y, name='', pen=None):
     if pen is None: pen = QtGui.QPen(self.autocolor.next(), 2)
     self.YscaleMax = min(10, 1.2 * max(y))
     self.YscaleMin = max(-10, 1.2 * min(y))
     curve = Qwt.QwtPlotCurve(name)
     curve.attach(self)
     curve.setPen(pen)
     curve.setStyle(Qwt.QwtPlotCurve.Dots)
     curve.setData(x, where(y == 0, 1e-99, y))
     self._plotdict[name] = curve
     self.clearZoomStack()
     return curve
Beispiel #5
0
 def attachCurve(self, x, y, name='', pen=None, style="Lines"):
     if pen is None: pen = QtGui.QPen(self.autocolor.next())
     self.YscaleMax = max(self.YscaleMax, 1.2 * max(y))
     self.YscaleMin = min(self.YscaleMin, max(1, 0.5 * min(y)))
     curve = Qwt.QwtPlotCurve(name)
     curve.attach(self)
     curve.setPen(pen)
     curve.setStyle(getattr(Qwt.QwtPlotCurve, style))
     curve.setData(x, where(y == 0, 1e-99, y))
     self._plotdict[name] = curve
     self.clearZoomStack()
     return curve
    def __init__(self, parent=None):
        super(PlottingDataMonitor, self).__init__(parent)

        self.monitor_active = False
        self.com_monitor = None
        self.livefeed = LiveDataFeed()
        self.temperature_samples = []
        self.timer = QTimer()

        # menu
        #
        self.file_menu = self.menuBar().addMenu("&File")
        selectport_action = QAction('Select TTY &Port...', self)
        selectport_action.triggered.connect(self.on_select_port)
        self.file_menu.addAction(selectport_action)

        self.start_action = QAction('&Start monitor')
        self.start_action.triggered.connect(self.on_start)
        self.start_action.setEnabled(False)
        self.file_menu.addAction(self.start_action)

        self.stop_action = QAction('&Stop monitor')
        self.stop_action.triggered.connect(self.on_stop)

        # main widget
        #
        # port
        portname_label = QLabel('tty port:')
        self.portname = QLineEdit()
        self.portname.setEnabled(False)
        self.portname.setFrame(False)
        portname_layout = QHBoxLayout()
        portname_layout.addWidget(portname_label)
        portname_layout.addWidget(self.portname, 0)
        portname_layout.addStretch(1)
        portname_groupbox = QGroupBox('Port')
        portname_groupbox.setLayout(portname_layout)

        # plot widget
        self.plot = qwt.QwtPlot(self)
        self.plot.setCanvasBackground(Qt.black)
        self.plot.setAxisTitle(qwt.QwtPlot.xBottom, 'Time')
        self.plot.setAxisScale(qwt.QwtPlot.xBottom, 0, 10, 1)
        self.plot.setAxisTitle(qwt.QwtPlot.yLeft, 'Temperature')
        self.plot.setAxisScale(qwt.QwtPlot.yLeft, 0, 250, 40)
        self.plot.replot()

        # curve widget
        self.curve = qwt.QwtPlotCurve('')
        self.curve.setRenderHint(qwt.QwtPlotItem.RenderAntialiased)
        pen = QPen(QColor('limegreen'))
        pen.setWidth(2)
        self.curve.setPen(pen)
        self.curve.attach(self.plot)

        # dial
        #
        self.dial = QDial()
        self.dial.setNotchesVisible(True)
        self.dial.setRange(0, 20)
        self.dial.setValue(10)
        self.dial.valueChanged.connect(self.on_dial_change)

        self.dial_label = QLabel('Update speed = %s (Hz)' % self.dial.value())
        self.dial_label.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        dial_layout = QVBoxLayout()
        dial_layout.addWidget(self.dial)
        dial_layout.addWidget(self.dial_label)

        # plot layout
        plot_layout = QVBoxLayout()
        plot_layout.addWidget(self.plot)
        plot_layout.addLayout(dial_layout)

        plot_groupbox = QGroupBox('Temperature')
        plot_groupbox.setLayout(plot_layout)

        # main
        self.main_frame = QWidget()
        main_layout = QVBoxLayout()
        main_layout.addWidget(portname_groupbox)
        main_layout.addWidget(plot_groupbox)
        main_layout.addStretch(1)
        self.main_frame.setLayout(main_layout)

        self.setCentralWidget(self.main_frame)

        # status
        #
        self.status_text = QLabel('Monitor idle')
        self.statusBar().addWidget(self.status_text, 1)
Beispiel #7
0
 def set_data(self, datax, datay, pen):
     curve = qwt.QwtPlotCurve("Curve 1")
     curve.setRenderHint(qwt.QwtPlotItem.RenderAntialiased)
     curve.setData(datax, datay)
     curve.setPen(pen)
     curve.attach(self)
Beispiel #8
0
transform.rotate(-30.0)
path = transform.map(path)

pen = QG.QPen(QC.Qt.black, 2)
pen.setJoinStyle(QC.Qt.MiterJoin)

symbol = qwt.QwtSymbol()
symbol.setPen(pen)
symbol.setBrush(QC.Qt.red)
symbol.setPath(path)
symbol.setPinPoint(QC.QPointF(0.0, 0.0))
symbol.setSize(10, 14)

# --- Test it within a simple plot ---

curve = qwt.QwtPlotCurve()
curve_pen = QG.QPen(QC.Qt.blue)
curve_pen.setStyle(QC.Qt.DotLine)
curve.setPen(curve_pen)
curve.setSymbol(symbol)
x = np.linspace(0, 10, 10)
curve.setData(x, np.sin(x))

plot = qwt.QwtPlot()
curve.attach(plot)
plot.resize(600, 300)
plot.replot()
plot.show()

plot.grab().save(
    osp.join(osp.abspath(osp.dirname(__file__)), "images", "symbol_path_example.png")