diff --git a/kabuki.py b/kabuki.py index c702538..c164ff6 100644 --- a/kabuki.py +++ b/kabuki.py @@ -6,21 +6,25 @@ from bokeh.plotting import curdoc from bokeh.layouts import column from cacher import cacher -from plots import Plot0D, Plot2D +from plots import Plot0D, Plot1D, Plot2D from sources import Camera, Source src0 = Source("MTEST:RAND0") +src1 = Source("MTEST:ARR") src2 = Camera("MTEST:CHAN-IMAGE:FPICTURE") cache0 = cacher.add_source(src0) -cache2 = cacher.add_source(src2) +cache1 = cacher.add_source(src1) +cache2 = cacher.add_source(src2, size=1) p0 = Plot0D() +p1 = Plot1D() p2 = Plot2D() def update(): p0.set(*cache0.xy) + p1.set(cache1.latest) p2.set(cache2.latest) @@ -30,6 +34,7 @@ doc.add_periodic_callback(update, 1000) plt = column( p0.fig, + p1.fig, p2.fig ) diff --git a/plot1d.py b/plot1d.py new file mode 100644 index 0000000..5b094d1 --- /dev/null +++ b/plot1d.py @@ -0,0 +1,33 @@ +import numpy as np + +from bokeh.plotting import figure +from bokeh.models import ColumnDataSource + + +class Plot1D: + + def __init__(self): + data = { + "x": [], + "y": [] + } + + self.source = source = ColumnDataSource(data=data) + + self.fig = fig = figure() + fig.line(x="x", y="y", source=source) + fig.circle(x="x", y="y", source=source) + + + def set(self, y): + x = np.arange(len(y)) + + data = { + "x": x, + "y": y + } + + self.source.data.update(data) + + + diff --git a/plots.py b/plots.py index 098e469..e3649ca 100644 --- a/plots.py +++ b/plots.py @@ -1,6 +1,6 @@ from plot0d import Plot0D -#from plot1d import Plot1D +from plot1d import Plot1D from plot2d import Plot2D