Matplotlib and Seaborn produce static plots, whereas Bokeh produces interactive plots. This means when the user interacts with these plots, they change accordingly.
Plots can be embedded as output of Flask or Django enabled web applications. Jupyter notebook can also be used to render these plots.
Dependencies of Bokeh −
Numpy Pillow Jinja2 Packaging Pyyaml Six Tornado Python−dateutil
Installation of Bokeh on Windows command prompt
pip3 install bokeh
Installation of Bokeh on Anaconda prompt
conda install bokeh
Following is an example −
From bokeh.plotting import figure, output_file, show
my_fig = figure(plot_width = 400, plot_height = 300) my_fig.rect(x = 11,y = 11,width = 150, height = 75, width_units = 'screen', height_units = 'screen') my_fig.square(x = 2,y = 3,size = 80, color = 'blue') my_fig.ellipse(x = 7,y = 6, width = 30, height = 10, fill_color = None, line_width = 2) my_fig.oval(x = 6,y = 6,width = 2, height = 1, angle = -0.4) show(my_fig)
The required packages are imported, and aliased.
The figure function is called along with plot width and height.
The ‘output_file’ function is called to mention the name of the html file that will be generated.
The ‘rect’, ‘square’, ‘ellipse’, and ‘oval’ functions present in Bokeh are called, along with data.
The ‘show’ function is used to display the plot.