Files
kabuki/plot1d.py
2021-06-02 16:44:42 +02:00

40 lines
694 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, name=None):
data = {
"x": [],
"y": []
}
self.source = source = ColumnDataSource(data=data)
fig = figure(name=name)
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)