Wednesday, January 22, 2020

Bokeh library



In the world of data visualization, there are three main libraries using Python that dominate the market, and these are as follows:
  1. Matplotlib
  2. Seaborn
  3. Bokeh
The first two, Matplotlib and Seaborn, let you plot static plots—plots that do not change and plots that cannot be interacted with. These plots are useful and add value when performing exploratory data analysis, as they are quick and easy to implement and very fast to execute.

The third plotting library, Bokeh, lets you plot interactive plots—plots that change when the user interacts with them. These plots are useful when you want to give your audience a wide range of options and tools for inferring and looking at data from various angles. Bokeh has a few dependencies. In order to use Bokeh, ensure that the following packages are already installed:

NumPy
Jinja2
Six
Requests
Tornado >= 4.0
PyYaml
DateUtil

If you're using Python 2.7, ensure that you have all the afore mentioned packages along with: Futures. If you have all of your Python packages installed and managed using a distribution such as Anaconda, you can install Bokeh using your Bash Terminal or a Windows Prompt using the following code:

conda install bokeh

You can also install Bokeh using PyPi for Python 2 via the following code:

pip install bokeh

You can install Bokeh using PyPi for Python 3 via the following code:

pip3 install bokeh

If you already have Bokeh installed and require an update, simply enter the following code in your terminal or shell:

sudo pip3 install bokeh --upgrade

Once you have installed Bokeh, you will want to verify that it is correctly installed. In order to verify the installation and create all your Bokeh plots, you'll need a Jupyter Notebook. You can verify your installation of Bokeh by generating a simple line plot using a Jupyter Notebook with the following code:

from bokeh.plotting import figure, output_file, show
#HTML file to output your plot into
output_file("bokeh.html")
#Constructing a basic line plot
x = [1,2,3]
y = [4,5,6]
p = figure()
p.line(x,y)
show(p)


This should open up a new tab on your browser with a plot illustrated as follows:

Share:

0 comments:

Post a Comment