> For the complete documentation index, see [llms.txt](https://fennaf.gitbook.io/bfvm19prog1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fennaf.gitbook.io/bfvm19prog1/data-visualisation/untitled.md).

# Bokeh introduction

source: https\://github.com/PacktPublishing/Hands-on-Data-Visualization-with-Bokeh

### Key definitions

The following are some key definitions related to Bokeh

* Applications: The Bokeh application is a rendered document that runs in the browser
* Glyphs: The building blocks of Bokeh, the geometric shapes that make up every element in the plot, like lines, rectangles, or circles.

![glyphs explained (www.DataCamp.com)](https://3769175098-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MJvb9AjGRgb32WfBeFy%2F-MK12CR4IXUxLb0GwWvR%2F-MK1FQo8iL7ChobFxk8a%2FScreenshot%202020-10-19%20at%2021.05.40.png?alt=media\&token=b7aed915-100c-4a98-b9c0-b55c12b9c27a)

* Widgets: sliders, dropdown menus, and tools to make the plot interactive&#x20;

### Plot output

You can use `output_file` to render your plot as an HTML file

```python
output_file('plot.html')
```

Or you can use directly in a jupyter notebook using&#x20;

```
output_notebook()
```

### Interface

Bokeh provides a plotting interface known as `bokeh.plotting`. The interface is the `Figure` class, which makes it possible to draw up the plot or plots on a 'canvas'. &#x20;

```python
from bokeh.plotting import figure
p = figure(plot_width = 500, plot_height = 400, tools="pan, hover")
```

&#x20;The variable p holds information about the plot including the width, height and the tools that will be used. Since `figure` is the main class, methods such as line, lables, legends  and so on can be added to our diagram to create the plot

```python
p.line(x, y)
p.xaxis.axis_label = 'CO2 (mg/l)'
p.yaxis.axis_label = 'enzyme activity'
```

When the plot is drawn the plot can be outputted:&#x20;

```python
output_file('line_plot.html') # not in the case of using notebook
show(p)
```
