예제 #1
0
class Plot(QwtPlot):
    """
    The plot follows one or more variables through time.
    It keeps track of the variables.
    """
    def __init__(self, parent):
        QwtPlot.__init__(self, parent)
        self.variables = []
        self.insertLegend(QwtLegend(self), QwtPlot.TopLegend)
        self.setCanvasBackground(Qt.white)
        self.magnifier = QwtPlotMagnifier(self.canvas())
        self.magnifier.setAxisEnabled(QwtPlot.xBottom, False)
        self.magnifier.setAxisEnabled(QwtPlot.yLeft, True)
        self.panner = QwtPlotPanner(self.canvas())
        self.panner.setAxisEnabled(QwtPlot.xBottom, False)
        self.panner.setAxisEnabled(QwtPlot.yLeft, True)

    def add_curve(self, label, expression, color=None):
        self.variables.append(PlotVariable(label, expression, self, color))

    def add_data(self, data):

        for variable in self.variables:
            if variable.expression not in data:
                print("No value for {}".format(variable.expression))
            else:
                variable.add_point(data['time'], data[variable.expression])

    def clear_data(self):
        for v in self.variables:
            v.clear_data()
class Plot(QwtPlot):

    """
    The plot follows one or more variables through time.
    It keeps track of the variables.
    """

    def __init__(self, parent):
        QwtPlot.__init__(self, parent)
        self.variables = []
        self.insertLegend(QwtLegend(self), QwtPlot.TopLegend)
        self.setCanvasBackground(Qt.white)
        self.magnifier = QwtPlotMagnifier(self.canvas())
        self.magnifier.setAxisEnabled(QwtPlot.xBottom, False)
        self.magnifier.setAxisEnabled(QwtPlot.yLeft, True)
        self.panner = QwtPlotPanner(self.canvas())
        self.panner.setAxisEnabled(QwtPlot.xBottom, False)
        self.panner.setAxisEnabled(QwtPlot.yLeft, True)

    def add_curve(self, label, expression, color=None):
        self.variables.append(PlotVariable(label, expression, self, color))

    def add_data(self, data):

        for variable in self.variables:
            if variable.expression not in data:
                print("No value for {}".format(variable.expression))
            else:
                variable.add_point(data['time'], data[variable.expression])

    def clear_data(self):
        for v in self.variables:
            v.clear_data()
class QwtPlotE(QwtPlot):
    """a slightly enhanced version of QwtPlot which already has some sugar on it"""
    def __init__(self, *arg):
        QwtPlot.__init__(self, *arg)
        self.plotLayout().setAlignCanvasToScales(True)
        self.setCanvasBackground(Qt.white)
        self.legend = QwtLegend()
        self.legend.setItemMode(QwtLegend.ClickableItem)
        self.insertLegend(self.legend, QwtPlot.TopLegend)
        self.grid = QwtPlotGrid()
        self.grid.attach(self)
        self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        self.zoomer = QwtPlotZoomer(QwtPlot.xBottom, QwtPlot.yLeft, QwtPicker.DragSelection,
            QwtPicker.AlwaysOn, self.canvas())
        self.zoomer.setRubberBandPen(QPen(Qt.green))
        self.zoomer.setTrackerPen(QPen(Qt.red))
        self.magnifier = QwtPlotMagnifier(self.canvas())
        self.panner = QwtPlotPanner(self.canvas())
        self.panner.setMouseButton(Qt.LeftButton, Qt.ControlModifier)
        self.connect(self, SIGNAL("legendClicked(QwtPlotItem*)"), self.togglePlotItemVisibility)

    def togglePlotItemVisibility(self, plotItem):
        """Toggle the visibility of a plot item"""
        plotItem.setVisible(not plotItem.isVisible())
        self.replot()
예제 #4
0
 def __init__(self, parent):
     QwtPlot.__init__(self, parent)
     self.variables = []
     self.insertLegend(QwtLegend(self), QwtPlot.TopLegend)
     self.setCanvasBackground(Qt.white)
     self.magnifier = QwtPlotMagnifier(self.canvas())
     self.magnifier.setAxisEnabled(QwtPlot.xBottom, False)
     self.magnifier.setAxisEnabled(QwtPlot.yLeft, True)
     self.panner = QwtPlotPanner(self.canvas())
     self.panner.setAxisEnabled(QwtPlot.xBottom, False)
     self.panner.setAxisEnabled(QwtPlot.yLeft, True)
 def __init__(self, parent):
     QwtPlot.__init__(self, parent)
     self.variables = []
     self.insertLegend(QwtLegend(self), QwtPlot.TopLegend)
     self.setCanvasBackground(Qt.white)
     self.magnifier = QwtPlotMagnifier(self.canvas())
     self.magnifier.setAxisEnabled(QwtPlot.xBottom, False)
     self.magnifier.setAxisEnabled(QwtPlot.yLeft, True)
     self.panner = QwtPlotPanner(self.canvas())
     self.panner.setAxisEnabled(QwtPlot.xBottom, False)
     self.panner.setAxisEnabled(QwtPlot.yLeft, True)
 def __init__(self, *arg):
     QwtPlot.__init__(self, *arg)
     self.plotLayout().setAlignCanvasToScales(True)
     self.setCanvasBackground(Qt.white)
     self.legend = QwtLegend()
     self.legend.setItemMode(QwtLegend.ClickableItem)
     self.insertLegend(self.legend, QwtPlot.TopLegend)
     self.grid = QwtPlotGrid()
     self.grid.attach(self)
     self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
     self.zoomer = QwtPlotZoomer(QwtPlot.xBottom, QwtPlot.yLeft, QwtPicker.DragSelection,
         QwtPicker.AlwaysOn, self.canvas())
     self.zoomer.setRubberBandPen(QPen(Qt.green))
     self.zoomer.setTrackerPen(QPen(Qt.red))
     self.magnifier = QwtPlotMagnifier(self.canvas())
     self.panner = QwtPlotPanner(self.canvas())
     self.panner.setMouseButton(Qt.LeftButton, Qt.ControlModifier)
     self.connect(self, SIGNAL("legendClicked(QwtPlotItem*)"), self.togglePlotItemVisibility)
예제 #7
0
 def __init__(self, canvas):
     QwtPlotPanner.__init__(self, canvas)
     self.setMouseButton(Qt.MidButton)
예제 #8
0
 def __init__(self, canvas):
     QwtPlotPanner.__init__(self, canvas)
     self.setMouseButton(Qt.MidButton)