Last active
June 26, 2019 01:39
-
-
Save AndresMWeber/54d641035435c5ae47e9375c4f93c027 to your computer and use it in GitHub Desktop.
Showing where to put the source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PlotLoop(object): | |
def __init__(self): | |
self.data = Data('data_source_file') | |
self.source = ColumnDataSource(data=dict(xs=np.random.rand(50, 2).tolist(), ys=np.random.rand(50, 2).tolist())) | |
self.init_plot() | |
def init_plot(self): | |
""" Initialize the plot with data from self.data | |
""" | |
plot = Plot(title=None, | |
plot_width=600, | |
plot_height=600, | |
min_border=0, | |
toolbar_location=None) | |
glyph = MultiLine(xs="xs", ys="ys", line_color="#8073ac", line_width=0.1) | |
plot.add_glyph(source, glyph) | |
xaxis = LinearAxis() | |
plot.add_layout(xaxis, 'below') | |
yaxis = LinearAxis() | |
plot.add_layout(yaxis, 'left') | |
plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) | |
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) | |
curdoc().add_root(plot) | |
def update(self): | |
self.source.data = self.data.update() | |
loop = PlotLoop() | |
curdoc().add_periodic_callback(loop.update, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment