Differences in BokehJS vs Python : expected usage

Hello, folks!
As I’ve mentioned in this forum on prior posts, I’ve been translating my team’s plotting code from (A) server-side python capture and rendering, to (B) server-side capture only and client-side rendering with BokehJS and websockets.
As promised here, I’ve tracked the main differences I’ve encountered between the expected usage in Python vs BokehJS, based on the available documentation. I’ve also put together a collection of minimal examples and workarounds (where possible) loosely based on the documentation’s original “minimal example”.

Issues in 2.3.0 and 2.2.3:

Descriptions here, links below.

  1. var plot = new Bokeh.Plotting.figure({title:"some title"}) replaces plot.title (Title() object by default) with provided string. Python casts string to the underlying Title() object.
  2. Bokeh.Plotting.gridplot() does not seem to inherit sizing_mode from underlying plots, or default is different. To match expected behavior with sizing_mode:stretch_width (for example) from Python flavor, sizing mode must be explicitly stated for both the figure() and the gridplot() objects
  3. Palette is available under Bokeh.Charts but not under Bokeh.Plotting; to use with, say, image(), the palette argument must be provided as a color string array, rather than as a string.
  4. Setting plot.x_range.start and plot.x_range.end, or plot.x_range.range_padding to adjust whitespace around glyphs on X axis is not persistent across “resets”; to match expected behavior from Python output, set plot.x_range.range_padding and plot.x_range._initial_range_padding. (Same for Y axis)
  5. plot.line([0,1],[0,1],{name:“the_name”}) sets renderer.glyph.name, rather than renderer.name; the latter seems to be used for HoverTool under ‘$name’
  6. Bokeh.Widgets.Div() does not include div.toolbar.tools (== []) to facilitate using in a custom Bokeh.Plotting.gridplot(); or gridplot() fails to check property exists before accessing; throws Uncaught TypeError: Cannot read property 'tools' of undefined

Links to minimal code for the issues above:

The code samples below include comment blocks to quickly switch between 2.2.3 and 2.3.0, as well as some additional commentary in context.

  1. bokehjs_title :
    shows both methods of title creation discussed above, with a button for dynamic updates to the title text
  2. bokehjs_sizing_mode :
    shows the behavior for both sizing_mode approaches above
  3. bokehjs_palette :
    shows three approaches to palette selection for Bokeh.Plotting.image()
  4. bokehjs_range_padding :
    shows range padding behavior across resets; click reset on the figure to test behavior
  5. bokehjs_glyph_name :
    shows name inheritance behavior; use hover tool to inspect name on both lines
  6. bokehjs_div_tools :
    shows a gridplot composed of a Div widget and a figure; comment Div toolbar definition to trigger gridplot failure

Fixed in 2.3.0

The following was an issue in 2.2.3 but behaves as expected in 2.3.0; recorded here for reference.

  1. Setting plot.frame_width while using sizing_mode:'fixed'does not resize canvas as expected; takes effect only after changing plot.width or plot.plot_width. Test: use frame_width, then (1) do nothing to render with default 600px with, or (2) set plot_width = null to make frame_width take over.
    bokehjs_frame_width :
    shows two plots using sizing_mode:'fixed' and frame_width; only one triggers size adjustment manually by changing plot_width after the figure is created.

@Bryan and team, I’m not sure these necessarily warrant long-term expansion to the docs as I had suggested in the original thread linked above (also here), since I expect some of this behavior might need to be updated; but they certainly warrant documenting for current users, I think. Is there a good place in the docs for what amounts to temp examples? Or, if you believe these should be added to the docs anyway, I’ll be happy to draft an update on GitHub. I await your guidance on how best to share this with the wider bokeh user community!

2 Likes

@oviquezr Thanks for the detailed notes, te best place for things like this is in the Migration Guide section of the release notes. If you’d like to submit a PR to add a section to the file at bokeh/2.3.0.rst at branch-2.4 · bokeh/bokeh · GitHub (note: against the branch-2.3 branch, not against branch-2.4) then I can manually re-deploy that page of the docs.

For now, you could just add the minimal descriptions, if we want to link to example code on codepen, etc. that will require more planning and coordination (e.g. a project account to use).

Which touches on a more general issue: it would be really great for more active users of BokehJS to become directly involved in the development cycle (e.g. active in the tracker, helping with testing, docs, examples before a release). I’d very much like BokehJS to become more on par with the Python side, as a standalone library. But realistically, that will require more help over time.

1 Like

Adding follow-up here, for completeness. The issues presented above have now been added to the GitHub issue tracker:

1 Like