1

Cross-post on Bokeh forums: https://discourse.bokeh.org/t/display-json-item-serialized-json-in-jupyter-notebook/7245/3

I've serialized my Bokeh plot to json using bokeh.embed.json_item, as described in the documentation: https://docs.bokeh.org/en/latest/docs/reference/embed.html#bokeh.embed.json_item

I now want to load it again in Python (Jupyter notebook). How do I do so? The documentation only mentions loading it using JavaScript and embedding it on a webpage: https://docs.bokeh.org/en/latest/docs/user_guide/embed.html

One way to do it is by displaying an HTML object in the IPython notebook as follows:

from IPython.core.display import display, HTML
html_plot = f'''
<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js"
        crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"
        crossorigin="anonymous"></script>
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.3.min.js"
        crossorigin="anonymous"></script>
</head>
<body>
  <div id="myplot"></div>
  <script>
  item = {plot_json}
  Bokeh.embed.embed_item(item, "myplot");
  </script>
</body>
'''
display(HTML(html_plot))

However, this does not get me back the bokeh Figure object which I can manipulate.

Abhishek Divekar
  • 1,131
  • 2
  • 15
  • 31

1 Answers1

0

As of Bokeh 2.3 re-ingesting the exported JSON back in to Python is still an open issue.

bigreddot
  • 33,642
  • 5
  • 69
  • 122