I think there is a BUG in the adding text Glyph to a plot. Please find below the sample plot which does not create “add text” to the plot.
Just copy and paste the below code, you will see the issue. Thanks for your great package.
My Ipython, Pandas, and Bokeh Versions:
IPython - 4.0.0
Pandas - 0.16.2
Bokeh - 0.10.0
--------------------------------------- Copy From here ------------------------------------------------
from bokeh.io import output_notebook, show
from bokeh.sampledata.autompg import autompg as df
from IPython import version as ipython_version
from pandas import version as pandas_version
from bokeh import version as bokeh_version
output_notebook()
print “IPython - %s” % ipython_version
print “Pandas - %s” % pandas_version
print “Bokeh - %s” %bokeh_version
from bokeh.models import Range1d, Plot
def get_plot():
xdr = Range1d(1600, 5500)
ydr = Range1d(5, 25)
plot = Plot(
x_range = xdr,
y_range = ydr,
title = “”,
plot_width = 800,
plot_height = 400,
outline_line_color = None,
toolbar_location = None,
responsive = True)
return plot
AXIS_FORMATS = dict(
minor_tick_in = None,
minor_tick_out = None,
major_tick_in = None,
major_label_text_font_size = “10pt”,
major_label_text_font_style = “normal”,
axis_label_text_font_size = “10pt”,
axis_line_color = ‘#AAAAAA’,
major_tick_line_color = ‘#AAAAAA’,
major_label_text_color = ‘#666666’,
major_tick_line_cap = “round”,
axis_line_cap = “round”,
axis_line_width = 1,
major_tick_line_width = 1,)
from bokeh.models import LinearAxis, SingleIntervalTicker
def add_axes(plot):
xaxis = LinearAxis (SingleIntervalTicker(interval = 500), axis_label = “Children per women”, **AXIS_FORMATS)
yaxis = LinearAxis (SingleIntervalTicker(interval = 2.5), axis_label = “Children per women”, **AXIS_FORMATS)
plot.add_layout(xaxis, ‘below’)
plot.add_layout(yaxis, ‘left’)
return plot
from bokeh.models import ColumnDataSource, Text
text_source = ColumnDataSource({‘year’: ‘71’})
def add_text(plot):
plot = add_axes(plot)
manually create your glyph, before, we alwaays write .circle or .line, …
(so for alll those methose this is actually what is going on under the hood)
text = Text(x=2, y=35, text=‘year’, text_font_size=‘150pt’, text_color=’#EEEEEE’)
plot.add_glyph(text_source, text)
return plot
from bokeh.models import Circle, HoverTool
render_source = ColumnDataSource(df)
def add_circle(plot):
plot = add_text(plot)
circle_glyph = Circle (x = ‘weight’, y = ‘accel’, size = ‘cyl’, fill_alpha = 0.8)
circle_renderer = plot.add_glyph(render_source, circle_glyph)
tooltips = “@index”
plot.add_tools(HoverTool(tooltips = tooltips, renderers = [circle_renderer]))
return plot
show(add_circle(get_plot()))