In [ ]:
from numpy import pi, arange, sin, cos, ones_like
In [ ]:
from bokeh import load_notebook
from bokeh.document import Document
from bokeh.glyphs import Circle
from bokeh.objects import (
Plot, DataRange1d, LinearAxis, Grid, ColumnDataSource, PanTool, WheelZoomTool
)
In [ ]:
x = arange(-2*pi, 2*pi, 0.1)
y = sin(x)
width = ones_like(x) * 0.02
height = ones_like(x) * 0.2
In [ ]:
source = ColumnDataSource(data=dict(x=x, y=y,width=width, height=height))
xdr = DataRange1d(sources=[source.columns("x")])
ydr = DataRange1d(sources=[source.columns("y")])
In [ ]:
plot = Plot(x_range=xdr, y_range=ydr, min_border=80)
In [ ]:
circle = Circle(x="x", y="y", fill_color="red", size=5, line_color="black")
In [ ]:
plot.add_glyph(source, circle)
In [ ]:
xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')
yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')
In [ ]:
plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker) )
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
In [ ]:
plot.add_tools(PanTool(), WheelZoomTool())
In [ ]:
load_notebook(force=True)
In [ ]:
import IPython.core.displaypub as displaypub
from bokeh.embed import notebook_div
from bokeh.utils import publish_display_data
data = {'text/html': notebook_div(plot)}
publish_display_data(data)
In [ ]: