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()
Пример #2
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()
Пример #3
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)