diff --git a/plotdesc.py b/plotdesc.py new file mode 100644 index 0000000..bea0899 --- /dev/null +++ b/plotdesc.py @@ -0,0 +1,37 @@ +import pyqtgraph as pg +from theme import pg_plot_style + + +class PlotDescription: + + def __init__(self, title=None, xlabel=None, ylabel=None): + self.title = title + self.xlabel = xlabel + self.ylabel = ylabel + self.xs = [] + self.ys = [] + self.style = pg_plot_style() + + + def append(self, xy): + x, y = xy + self.xs.append(x) + self.ys.append(y) + + + def make_plot(self, plotwidget): + res = plotwidget.plot(self.xs, self.ys, **self.style) + + if self.title: + plotwidget.setTitle(self.title) + + if self.xlabel: + plotwidget.setLabel("bottom", self.xlabel) + + if self.ylabel: + plotwidget.setLabel("left", self.ylabel) + + return res + + +