Set title and location of plot in Bokeh
p.title.text = title p.title_location = "above"
References
http://docs.bokeh.org/en/1.3.2/docs/user_guide/styling.html#title
Daily Notes of a Programmer
p.title.text = title p.title_location = "above"
References
http://docs.bokeh.org/en/1.3.2/docs/user_guide/styling.html#title
p = figure(width=300, height=300, x_axis_label='Initial xlabel') p.xaxis.axis_label = 'New xlabel'
References
https://stackoverflow.com/questions/24131501/x-and-y-axis-labels-for-bokeh-figure
p.sizing_mode = "scale_both"
References
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html#sizing-mode
Embedding a single plot at a time with output_file()
<iframe src="/assets/img/Bokeh/flowers.html" sandbox="allow-same-origin allow-scripts" width="100%" height="500" scrolling="no" seamless="seamless" frameborder="0"> </iframe>
References
https://p-mckenzie.github.io/2017/12/01/embedding-bokeh-with-github-pages/
from bokeh.sampledata.glucose import data from bokeh.plotting import figure, show, output_file from bokeh.models import BoxAnnotation output_file("box_annotation.html", title="box_annotation.py example") TOOLS = "pan,wheel_zoom,box_zoom,reset,save" #reduce data size data = data.loc['2010-10-06':'2010-10-13'] p = figure(x_axis_type="datetime", tools=TOOLS) p.line(data.index.to_series(), data['glucose'], line_color="gray", line_width=1, legend_label="glucose") low_box = BoxAnnotation(top=80, fill_alpha=0.1, fill_color='red') mid_box = BoxAnnotation(bottom=80, top=180, fill_alpha=0.1, fill_color='green') high_box = BoxAnnotation(bottom=180, fill_alpha=0.1, fill_color='red') p.add_layout(low_box) p.add_layout(mid_box) p.add_layout(high_box) p.title.text = "Glucose Range" p.xgrid[0].grid_line_color=None p.ygrid[0].grid_line_alpha=0.5 p.xaxis.axis_label = 'Time' p.yaxis.axis_label = 'Value' show(p)
References
https://docs.bokeh.org/en/latest/docs/user_guide/annotations.html#box-annotations
from datetime import datetime as dt import time from bokeh.sampledata.daylight import daylight_warsaw_2013 from bokeh.plotting import figure, show, output_file from bokeh.models import Span output_file("span.html", title="span.py example") p = figure(x_axis_type="datetime", y_axis_type="datetime") p.line(daylight_warsaw_2013.Date, daylight_warsaw_2013.Sunset, line_dash='solid', line_width=2, legend_label="Sunset") p.line(daylight_warsaw_2013.Date, daylight_warsaw_2013.Sunrise, line_dash='dotted', line_width=2, legend_label="Sunrise") start_date = time.mktime(dt(2013, 3, 31, 2, 0, 0).timetuple())*1000 daylight_savings_start = Span(location=start_date, dimension='height', line_color='green', line_dash='dashed', line_width=3) p.add_layout(daylight_savings_start) end_date = time.mktime(dt(2013, 10, 27, 3, 0, 0).timetuple())*1000 daylight_savings_end = Span(location=end_date, dimension='height', line_color='red', line_dash='dashed', line_width=3) p.add_layout(daylight_savings_end) p.title.text = "2013 Sunrise and Sunset times in Warsaw" p.yaxis.axis_label = 'Time of Day' show(p)
References
http://docs.bokeh.org/en/latest/docs/user_guide/annotations.html#spans
https://stackoverflow.com/questions/39426976/how-to-add-horizontal-line-span-to-the-box-plot-in-bokeh
https://stackoverflow.com/questions/28797330/infinite-horizontal-line-in-bokeh
p.toolbar.logo = None p.toolbar_location = None
References
https://stackoverflow.com/questions/32158939/python-bokeh-remove-toolbar-from-chart