from bokeh import mpl from bokeh.bbmodel import ContinuumModel p = mpl.PlotClient('defaultdoc', 'http://localhost:5006', 'nokey') import numpy as np import datetime import time source = ContinuumModel( 'ObjectArrayDataSource', data = [ {'x' : 1, 'y' : 5, 'z':3, 'radius':10}, {'x' : 2, 'y' : 4, 'z':3}, {'x' : 3, 'y' : 3, 'z':3, 'color':"red"}, {'x' : 4, 'y' : 2, 'z':3}, {'x' : 5, 'y' : 1, 'z':3}, ] ) plot = ContinuumModel('Plot') xdr = ContinuumModel( 'DataRange1d', sources = [{'ref' : source.ref(), 'columns' : ['x']}] ) ydr = ContinuumModel( 'DataRange1d', sources=[{'ref' : source.ref(), 'columns' : ['y']}], ) glyph_renderer = ContinuumModel( 'GlyphRenderer', data_source = source.ref(), xdata_range = xdr.ref(),
def render(self): source = self.source.dataSource() rend = ContinuumModel("Plot") _x_dr_ = ContinuumModel("DataRange1d", sources=[{"ref": source.ref(), "columns": ["x"]}]) _y_dr_ = ContinuumModel("DataRange1d", sources=[{"ref": source.ref(), "columns": ["y"]}]) glyph_renderer = ContinuumModel( "GlyphRenderer", data_source=source.ref(), xdata_range=_x_dr_.ref(), ydata_range=_y_dr_.ref(), glyphspec={ "type": "circle", "units": "screen", "x": {"field": "x"}, "y": {"field": "y"}, "fill": {"field": "color"}, "radius": {"field": "radius"}, }, ) xLinearAxis = ContinuumModel("LinearAxis", parent=rend.ref(), data_range=_x_dr_.ref(), orientation="bottom") yLinearAxis = ContinuumModel("LinearAxis", parent=rend.ref(), data_range=_y_dr_.ref(), orientation="left") rend.set("renderers", [glyph_renderer.ref()]) rend.set("axes", [xLinearAxis.ref(), yLinearAxis.ref()]) p.bbclient.upsert_all([glyph_renderer, source, rend, _x_dr_, _y_dr_, xLinearAxis, yLinearAxis]) p.show(rend)