added 1D example
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user