added PlotDescription

This commit is contained in:
2022-12-19 11:32:20 +01:00
parent 5ef1150193
commit fdea41fad4

37
plotdesc.py Normal file
View File

@ -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