Bokeh 1.2.0 Released

28 May 2019 / Bryan Van de Ven

We are pleased to announce the release of Bokeh 1.2!

This point release contains a few new features. Some highlights:

  • Styling options for fill patterns / hatching #6135
  • Built-in support for stacked areas and lines #8848
  • New title property for Legend #6769
  • Slider callback_policy now works for Bokeh Apps #4540

For full details, see the CHANGELOG and Release Notes. Additionally, examples for each release are uploaded to CDN. Click here to download.

If you are using Anaconda, Bokeh can most easily be installed by executing the command conda install -c bokeh bokeh . Otherwise, use pip install bokeh.


Before getting to the real content, it’s worth mentioning one important change: The Google Groups mailing list has been retired. In its place, there is now a Discourse instance for community discussions. All of the old content from the mailing list has been imported into the Disourse, and is now easily searchable! Switching to discourse has many benefits besides search: code formatting, math text, rich media, as well as search and traffic statistics for admins, that will help us better improve the site and our docs.

We have made it easy to log in with Google, GitHub, and Twitter (or you can create a email login). Check out the new Bokeh Discourse site today!


Fill Patterns

Even well before #6135, which is already a few years old at this point, I had wanted to be able to support fill patterns (or “hatching”) for things like bars are patches. I am pleased to report that Bokeh now supports a wide variety of Hatch Properties for specifying fill patterns:

 

These can be used with bar and patch type glyphs, and basic usage consists of setting the hatch_pattern value:

p.vbar(..., hatch_pattern="dot")

But typically you will want to tweak other hatch properties such as alpha, color, weight, or scale.

Besides these built-in hatch patterns, it’s also possible set fill patterns from any image, as long as the image is available at a URL (inline base64 data URLs will work too):

 

These are made by adding a named ImageURLTexture to hatch_extra, and then using that name as the hatch_pattern:

p.vbar(...,
       hatch_pattern=dict(value='image'),
       hatch_extra={"image": ImageURLTexture(url=url)})

Lastly, it should be mentioned that fill patterns also work for grid bands, which I personally think looks especially nice:

 

The bands above were configured with this code:

p.xgrid.band_hatch_pattern = "/"
p.xgrid.band_hatch_alpha = 0.6
p.xgrid.band_hatch_color = "lightgrey"
p.xgrid.band_hatch_weight = 0.5
p.xgrid.band_hatch_scale = 10

There are some other places that fill pattern support could still be added, such as various annotation classes. It’s not a lot of work and there are some example PRs that can be referenced, so this would make a great task for a new contributor!

Stacked Lines and Areas

New glyph functions for directed areas were added in Bokeh 1.2, as well as covenience methods to stack areas and lines.

First off, the varea and harea glyphs were added for drawing directed areas, which are filled regions between two series that share a common index.

These are nice enough on their own, but they are even more useful for making stacked area charts much easier to create:

 

There are new methods analogous to vbar_stack and hbar_stack for directed areas as well as lines:

  • varea_stack
  • harea_stack

for stacking directed areas, and

  • vline_stack
  • hline_stack

for stacking lines.

Just like the stack methods for bars, these accept a sequence of column names to stack, and return a list of glyph renderers. Any other arguments are broadcast across all the renderers. The plot above was generated with code like this:

colnames = ['y0', 'y1', 'y2', 'y3', 'y4', 'y5', 'y6']

p.varea_stack(colnames, x='index', color=colors, source=df,
              legend=[value(x) for x in colnames])

p.vline_stack(colnames, x='index', color="black", source=df)

For a full example, check out the updated stacked_area.py

Note that the example plot above also shows off the new legend title, by setting p.legend.title = "Things".

Slider Callback Policy

Bokeh sliders have a callback_policy property that allows for throttling responses to slider movements. Until now, this policy only functioned with CustomJS Javascript callbacks, and only with with old-style callback property (not with the newer, general purpose js_on_change).

In this release, a new value_throttled property has been added, that can trigger both JavaScript and Python callbacks (in a Bokeh server app):

slider.callback_policy = "mouseup"

# both of these will respect the callback policy now
slider.js_on_change('value_throttled', ...)
slider.on_change('value_throttled', ...)

The slider above specifies the “mouseup” callback policy, so the callbacks will only execute when the user releases the mouse after adjusting a slider, and not on any intermediate steps.

Note that the value property can also still be used to trigger callbacks —they will execute unconditionally on every movement.

Also note that the old-style callback property will be removed in Bokeh 2.0 in the near future. The general js_on_change and on_change mothods should be used going forward.

Seeking Testimonials and Use Cases

A potential avenue for funding Bokeh development in a signifiant way has opened up. The grant program is specifically targeting Open Source projects that are used in bio-sciences. If you use Bokeh in any way for anything bio-science related, please fill out the Google form below.

 

Help financially

Bokeh relies on paid cloud infrastucture to host the CDN files for BokehJS, serve the documentation and demos, and store CI build artifacts. Your contribution to NumFocus helps defray those costs.


As always, anyone interested in helping out should drop by the Dev Chat Channel and say hello!

Thanks,

Bryan Van de Ven