Hide several lines using Checkboxes and CustomJS in Python Bokeh

The main idea is to collect all line renderes in a list and pass this list to the CustomJS. There you can loop over this list again and apply your changes. Minimal Example import pandas as pd from bokeh.plotting import figure, show, output_notebook from bokeh.models import CheckboxGroup, CustomJS from bokeh.layouts import row output_notebook() df = … 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