Render hvPlot in jupyter notebooks on github with bokeh backend

Matplotlib and plotly can render on github from inside notebooks when they are pushed, creating impressive outputs directly available in the browser on github. It would be great if hvplot charts could be rendered inline in jupyter notebooks on github as well.

I tried wrapping plots as panels and using combinations of save and embed as described here: Display and Export — Panel v0.14.4

But over all I had no luck getting charts to render in github.

Does anyone know how this can be accomplished?

The notebook I am working in can be found here:

Any update on this? I would love to display hvplots on github with bokeh backend!

I think only GitHub pages work; python - Embedding interactive Bokeh or Plotly figures in Github-hosted site - Stack Overflow

Maybe https://htmlpreview.github.io/

Hey @LinuxIsCool, this is actually a limitation of Github that doesn’t render HTML/CSS/Javascript for security reasons, you can read more on their site Working with non-code files - GitHub Docs (funnily their example of what notebooks can’t be rendered well on Github is a Bokeh example). They advise using nbviewer when trying to visualize a notebook with interactive content.

Plotly offers ways to pick a different renderer (e.g. png, svg) and that can be used as a work around to save notebooks that can be visualized on Github, you can read more about it in this issue How to display plotly outputs on Github? · Issue #931 · plotly/plotly.py · GitHub. But I don’t think you can render an interactive Plotly plot on Github?

As for setting HoloViews to generate static Bokeh plots:

I think overall Plotly is better as producing static representations of its interactive plots compared to Bokeh.

1 Like

If you are ok with using Matplotlib or Plotly backend, then its possible.

The below can probably be simplified.

I find bokeh to be the most aesthetic and useful backend to work with. I really look forward to a day where I can embed static bokeh outputs into github. I’m not concerned with interactive functionality, just getting a static display would be really nice.

It’s a little surprising since the bokeh widgets have the ‘save’ tool which exports as png. I would think that would imply that there is an easy way to set outputs to be png in the notebook? I believe this is how plotly achieves rendering.

I believe the Bokeh ‘save’ tool relies on some browser capabilities and doesn’t involve Python, while what we’re trying to achieve is to create static plots running Python. Bokeh plots can be produced as PNG but you need Selenium + some browser drivers, so in the end it does rely on the browser but it’s all driven by Python. Plotly plots are generated thanks to GitHub - plotly/Kaleido: Fast static image export for web-based visualization libraries with zero dependencies that look like an interesting project. In general it’d be very cool for someone to explore that space and list the options available, and ideally do the work to improve Bokeh! :slight_smile:

2 Likes