Holoviews: Testing the bokeh Elements tutorial and matching the original

Created on 6 Dec 2015  路  20Comments  路  Source: holoviz/holoviews

I think it would be great to just copy the current Elements tutorial, set hv.notebook_extension(bokeh=True) at the top and make it available on the website (the tutorials could then be called Elements [matplotlib] and Elements [bokeh]. This would achieve a few things:

  1. Show some official bokeh examples on or website.
  2. Show how easy it is to use the same code and switch backends.
  3. Test our bokeh support.
  4. Show people the full range of things that can be done with the bokeh backend.

The main issues I can see are:

  1. Setting this up on Travis (I think bokeh is already installed though).
  2. Getting display tests working for bokeh. This may be tricky if there is a fair bit of randomness (e.g uuids) in the bokeh output given the same input.
tag bokeh tag testing docs

All 20 comments

I forgot to mention you'll need %output backend='bokeh' too (maybe notebook_extension should switch for you?). I also notice that some things still aren't available (e.g VectorField?) and when I run this cell, the rest of the notebook doesn't run:

data = [('one',8),('two', 10), ('three', 16), ('four', 8), ('five', 4), ('six', 1)]
bars = hv.Bars(data, kdims=[hv.Dimension('Car occupants', values='initial')], vdims=['Count'])
bars + bars[['one', 'two', 'three']]

I've already added a version of the Elements Tutorial using Bokeh. Do still need to get bokeh testing working though.

Ah, yes... I see that commit fro 19 hours ago. :-)

Though it would be good if it were made as similar to the original tutorial as possible (e.g the issue above). What do you think about effectively calling the output magic to switch backends when using notebook_extension(bokeh=True)? I guess it gets confusing if you load JS for multiple things because then it gets ambiguous...

Ok, I changed the title of the issue. I'm sure you are already aware of some of the following problems but they are worth listing here anyway:

  • The index isn't rendering properly.. e.g a line shows up as [``Element``](#Element). This is true for the normal tutorial too (dev section of the website).
  • In Histogram you get a warning: WARNING:root:Options: Invalid options ['show_grid'], valid options are: ...
  • I think I would be in favor of matching up the index between Elements and Bokeh_Elements for ease of reference. Then we can just be honest about which elements aren't supported in the bokeh backend. For instance, I don't see why HSV isn't listed in the bokeh version...surely that is trivial to support?

In general, I think the tutorials should be as similar to each other as possible..

What do you think about effectively calling the output magic to switch backends when using notebook_extension(bokeh=True)? I guess it gets confusing if you load JS for multiple things because then it gets ambiguous...

I would definitely be in favor of this, with the last JS set loaded determining the default backend. Maybe this is already the behavior?

In general I agree with Jean-Luc's comments above; making a full Bokeh version (with stubs where required) would make it be clearest about what's supported and what's not (and would spur us to support whatever isn't. There should also probably be a fairly short tutorial somewhere that's specific to Bokeh, describing and demonstrating what's available in that backend that's not available elsewhere (brushing, linking, callbacks?).

making a full Bokeh version (with stubs where required) would make it be clearest about what's supported and what's not (and would spur us to support whatever isn't.

These Elements could probably be supported fairly easily:

  • QuadMesh: Could be implemented as individual rectangles
  • Bars: Implemented in unmerged PR #339
  • HSV: Should be easy
  • Arrow: Should land in bokeh 0.11
  • VectorField: Could also use arrow glyph

These can't:

  • Surface
  • Scatter3D
  • Trisurface

here should also probably be a fairly short tutorial somewhere that's specific to Bokeh, describing and demonstrating what's available in that backend that's not available elsewhere (brushing, linking, callbacks?).

I've got a notebook for that, I'll do some minor tidying but it's almost ready to go.

I'd urge you to make the change of having notebook_extension(bokeh=True) switch to Bokeh automatically very soon, so that it goes into the next minor release. That way we can simplify our user instructions, when telling people about the Bokeh support.

I would definitely be in favor of this, with the last JS set loaded determining the default backend.

Yes, this makes sense. Definitely something we'll have for 1.4.1.

Agreed, it should simply load extensions for all available backends by default. For matplotlib that's a no-op but the plotly backend prototype has something similar.

Agreed, it should simply load extensions for all available backends by default.

That sounds useful to me (based on whether imports work or not, I presume?). Then if you supply an explicit list of 'resources' we should obey that.

It would mean that holoviews javascript wouldn't be included by default as soon as anything is set. E.g for initializing holoviews and bokeh _only_ (even if something else is available) you would use:

notebook_extension(holoviews=True, bokeh=True) 

Hmm; we may not be agreeing here. Why include more than one backend initialization by default? I would have thought that as a user, if I type:

hv.notebook_extension() 

I would get support for the default backend (currently matplotlib), and that if I type:

notebook_extension(bokeh=True) 

I would only get Bokeh support, and that if I type:

notebook_extension(bokeh=True, matplotlib=True) 

I would get support for both bokeh and matplotlib and make matplotlib the default (which I'd _expect_ from the left to right order, _even if_ Python won't actually respect that :-), and that if I type:

notebook_extension(bokeh=True, matplotlib=True, plotly=True) 

I'd get support for all three, with plotly as the default, falling back to matplotlib when that Element type isn't supported by Plotly, then falling back to bokeh for anything not supported by matplotlib.

I'm not saying that it has to be like this, or that it's reasonable to be like this, it's just how I would expect it to behave: no support for backends I'm not using and may never have heard of, no need to explicitly specify any backend using %output later, and a list of preferred backends, in order.

The idea of setting up fallbacks in this way is one Philipp and I have toyed with but we aren't completely convinced this is exactly the behavior we want. As it would also require some refactoring, this suggestion is something to think about after 1.4.1 is released.

For now what I have done (PR #374) is update notebook_extension to activate the last backend loaded in the resource list. As Jim noted, we can't know the specified order left-to-right using the keyword syntax:

notebook_extension(bokeh=True, matplotlib=True)

But now you can pass kwargs which is shorter and preserves the order:

notebook_extension('bokeh', 'matplotlib')

In this case, BokehJS would be loaded and the matplotlib backend would remain active. Specified the other way round and the bokeh backend would be automatically activated.

Looks good to me!

Are we going to try to implement the suggestion in #445 (backend icons) before we release 1.4.2?

I will also note that although the Bokeh Elements tutorial has been updated to be like original matplotlib one, part of this issue was about testing Bokeh plots, something that is not yet in place.

I think most of these changes have been implemented except for the suggestion in #455 which I think is a good idea. For this reason, I'll leave this issue open and reassign the milestone to v1.5.

We are now testing the bokeh element tutorial at least in Python 2. I think that addresses all the suggestions in this PR. In future we'll be splitting up the Element tutorial into individual examples so I'll close this issue now.

Do we have an issue to record something related we discussed: a page with thumbnails for all the elements (linking to the right place in the tutorials) and a toggle to switch between matplotlib/bokeh?

Just noticed missing Arrow support for bokeh in that Elements tutorial.

scene * hv.Text(0, 0.2, 'Adult\npenguins') + scene * hv.Arrow(0,-0.1, 'Baby penguin', 'v')

WARNING:root:OverlayPlot03380: No plotting class for Arrow type and bokeh backend found.

Right; as discussed in https://github.com/ioam/holoviews/pull/1196 that's the only non-3D Element not yet supported by the Bokeh backend.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asmith26 picture asmith26  路  4Comments

nbren12 picture nbren12  路  5Comments

ahuang11 picture ahuang11  路  3Comments

ericmjl picture ericmjl  路  3Comments

CurtLH picture CurtLH  路  3Comments