Files
grum/plotdesc.py
T
2022-12-19 12:28:51 +01:00

37 lines
732 B
Python

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