Book Image

Hands-On Data Visualization with Bokeh

By : Kevin Jolly
Book Image

Hands-On Data Visualization with Bokeh

By: Kevin Jolly

Overview of this book

Adding a layer of interactivity to your plots and converting these plots into applications hold immense value in the field of data science. The standard approach to adding interactivity would be to use paid software such as Tableau, but the Bokeh package in Python offers users a way to create both interactive and visually aesthetic plots for free. This book gets you up to speed with Bokeh - a popular Python library for interactive data visualization. The book starts out by helping you understand how Bokeh works internally and how you can set up and install the package in your local machine. You then use a real world data set which uses stock data from Kaggle to create interactive and visually stunning plots. You will also learn how to leverage Bokeh using some advanced concepts such as plotting with spatial and geo data. Finally you will use all the concepts that you have learned in the previous chapters to create your very own Bokeh application from scratch. By the end of the book you will be able to create your very own Bokeh application. You will have gone through a step by step process that starts with understanding what Bokeh actually is and ends with building your very own Bokeh application filled with interactive and visually aesthetic plots.
Table of Contents (10 chapters)

Exporting plots as PNG images

The plot generated above looks both impressive and informative at the same time. We might want to publish this plot on a website or in a magazine/journal as a .PNG image with a higher level of quality. Luckily for us, Bokeh offers this flexibility.

Bokeh can generate such images by using the export function. This function uses a browser called Webkit to save the plot in its memory and capture a screenshot. The dimensions of the generated image will be the same as that of the plot you created.

The first step is to install a dependency that this Bokeh functionality depends upon. This is called Phantomjs. You can install this package using Anaconda with the command shown here:

conda install selenium phantomjs pillow

The next step is to install Selenium using pip. We can do this by using the command shown here:

pip3 install selenium

The final step is...