Data tooltips in Bokeh don’t show data, showing ‘???’ instead

I was having the same problem. I found this reference useful. The tooltip for Sales would use the generic @height, e.g.: hover.tooltips = [(‘Sales’, ‘@height’)] Similarly, replacing @height with @y would give you the total sales for each year. I haven’t figured out how to use the tooltip to access the stacked categories or how … Read more

multi_line hover in bokeh

As of Bokeh 0.12.4 (earlier, actually but I forget the exact release) the hover tool supports mutli_line: from collections import defaultdict import numpy as np from scipy.stats import norm from bokeh.plotting import show, figure from bokeh.models import ColumnDataSource, HoverTool from bokeh.palettes import Viridis6 RT_x = np.linspace(118, 123, num=50) mass_spec = defaultdict(list) for scale, mz in … Read more

How do I work with images in Bokeh (Python)

You can use the ImageURL glyph (image_url plot method)to load images locally or from the web. from bokeh.plotting import figure, show, output_file output_file(‘image.html’) p = figure(x_range=(0,1), y_range=(0,1)) p.image_url(url=[‘tree.png’], x=0, y=1, w=0.8, h=0.6) ## could also leave out keywords # p.image_url([‘tree.png’], 0, 1, 0.8, h=0.6) show(p) One gotcha – if you graph only an image (and … Read more

How to do waffle charts in python? (square piechart)

I spent a few days to build a more general solution, PyWaffle. You can install it through pip install pywaffle The source code: https://github.com/gyli/PyWaffle PyWaffle does not use matshow() method, but builds those squares one by one. That makes it easier for customization. Besides, what it provides is a custom Figure class, which returns a … Read more

how to embed standalone bokeh graphs into django templates

Using the Embedding Bokeh Plots documentation example as suggested by Fabio Pliger, one can do this in Django: in the views.py file, we put: from django.shortcuts import render from bokeh.plotting import figure from bokeh.resources import CDN from bokeh.embed import components def simple_chart(request): plot = figure() plot.circle([1,2], [3,4]) script, div = components(plot, CDN) return render(request, “simple_chart.html”, … Read more

How do I use custom labels for ticks in Bokeh?

Fixed ticks can just be passed directly as the “ticker” value, and major label overrides can be provided to explicitly supply custom labels for specific values: from bokeh.plotting import figure, output_file, show p = figure() p.circle(x=[1,2,3], y=[4,6,5], size=20) p.xaxis.ticker = [1, 2, 3] p.xaxis.major_label_overrides = {1: ‘A’, 2: ‘B’, 3: ‘C’} output_file(“test.html”) show(p)