added PlotDescription
This commit is contained in:
37
plotdesc.py
Normal file
37
plotdesc.py
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user