37 lines
622 B
Python
37 lines
622 B
Python
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):
|
|
if y is None: #TODO: is this needed?
|
|
return
|
|
|
|
x = np.arange(len(y))
|
|
|
|
data = {
|
|
"x": x,
|
|
"y": y
|
|
}
|
|
|
|
self.source.data.update(data)
|
|
|
|
|
|
|