> For the complete documentation index, see [llms.txt](https://datalab-docs.datacamp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://datalab-docs.datacamp.com/guides/show-bokeh-and-pyvis-plots.md).

# Show Bokeh and Pyvis plots

DataLab supports most visualisation libraries available for Python and R like [matplotlib](https://matplotlib.org/stable/index.html) and [plotly](https://plotly.com/python/). Some visualisation libraries require special attention to correctly generate output in DataLab.

### Python

#### Bokeh ([docs](https://docs.bokeh.org/en/latest/))

DataLab does not natively support outputs from Bokeh. The guide outlined in the [Bokeh docs](https://docs.bokeh.org/en/latest/docs/user_guide/output/jupyter.html#classic-notebooks) for Jupyter notebooks is not supported. In DataLab it is required to generate a HTML output. You can use the following helper function to display a Bokeh graph:

```python
from IPython.display import HTML
from bokeh.embed import file_html
from bokeh.resources import CDN

def display_bokeh(bokeh_figure):
    return HTML(file_html(bokeh_figure, CDN))

```

#### Pyvis ([docs](https://pyvis.readthedocs.io/en/latest/index.html))

Pyvis writes outputs to HTML files. The following example contains a helper function `display_pyvis` which takes a pyvis graph and a name as arguments and will return the HTML output of the graph.

```python
# IMPORTS
from IPython.display import HTML
from pyvis import network as net
import networkx as nx

def display_pyvis(pyvis_graph, name):
    filename = f"{name}.html"
    pyvis_graph.save_graph(filename)
    return HTML(filename=filename)    


g = net.Network(notebook=True, cdn_resources='in_line')
nxg = nx.complete_graph(5)
g.from_nx(nxg)

display_pyvis(g, "pyvis-example")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://datalab-docs.datacamp.com/guides/show-bokeh-and-pyvis-plots.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
