added 1D example

This commit is contained in:
2021-05-20 23:44:43 +02:00
parent 0b46d992f0
commit d229d650f0
3 changed files with 41 additions and 3 deletions
+7 -2
View File
@@ -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
)
+33
View File
@@ -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)
+1 -1
View File
@@ -1,6 +1,6 @@
from plot0d import Plot0D
#from plot1d import Plot1D
from plot1d import Plot1D
from plot2d import Plot2D