Files
kabuki/plot1d.py

40 lines
674 B
Python

import numpy as np
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource
from buki import Object
class Plot1D(Object):
def __init__(self):
data = {
"x": [],
"y": []
}
self.source = source = ColumnDataSource(data=data)
fig = figure()
fig.line(x="x", y="y", source=source)
fig.circle(x="x", y="y", source=source)
super().__init__(fig)
def set(self, y):
if y is None: #TODO: is this needed?
return
x = np.arange(len(y))
data = {
"x": x,
"y": y
}
self.source.data.update(data)