☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How to show plots as png inside a notebook?

Community Supportbokeh
johann-petrak
johann-petrak

I am using Bokeh plots inside a (classical) Jupyter notebook and that works fine.

However, when converting the notebook to pdf or showing the notebook directly from github, none of the plots are shown.

I previously used the “plotly” library instead of Bokeh and there it was possible to
choose if the plot is shown as an interactive graph (which also cannot get converted to pdf or shown in github) or instead render the plot as png, svg, or some other static image inside the notebook. In that case the plot is visible after conversion or when viewing the notebook directly from github.

I could not find a similar option for Bokeh. Am I missing something? Is it possible with Bokeh to render a plot as a static image inline in a Jupyter notebook?

⌁   Link to post
johann-petrak
johann-petrak

So this basically means it is not possible for bokeh to produce the image data in memory / in the notebook only since with display method, each plot needs to get stored as a file somewhere first, right?
Which means also that the client code needs to somehow take care of cleaning up all the files when the notebook is exited or the program terminates?

This looks a bit clumsy to me TBH, it should not be hard, I think, for bokeh to produce the image data on the fly and send it to the output in a panel or the notebook without the necessity to store it in a file first? This is something that works quite simply in Plotly because with any invocation of show() one can specify the renderer for this, e.g. show(renderer=“png”) or show(renderer=“notebook”) which makes it easy to control how this is done for the entire notebook and e.g. choose a different renderer when the notebook gets converted to html or pdf

⌁   Link to post
Bryan
Bryan

So this basically means it is not possible for bokeh to produce the image data in memory

I didn’t say that, but you also didn’t specify what exactly you were after, so I gave you the simplest most common answer. You can also look at the lower level get_screenshot_as_png function that returns a PIL.Image. I’m not sure what Jupyter APIs if any are needed to display a PIL.Image inline in notebooks, so I can’t advise on that, but I would imagine it is possible.

⌁   Link to post

End of archived discussion · Replies are disabled