BOKEH
BOKEH
BOKEH
What is Bokeh?
• Python library
• To create an interactive visualizations
• Build beautiful graphics
• Without any javascript, we create a javascript coding for visualizations.
• Powerful tools for data visualizations
• Provides elegant ,concise, high performance with streaming datasets
Features
• Flexibility: It is used for common plotting requirements and used as a complex use cases
• Productivity: Bokeh can be easily interact with popular pydata tools such as Pandas and
Jupyter Notebook
• Interactivity: Bokeh creates interactive plots that change when the user interacts with them.
• Powerful: By adding custom Javscript,it is possible to generate visualizations for specialized
use-cases.
• Sharable: rendered in Jupyter notebooks
• Open source:Free to use
Simple representation
Plots with glyphs
• With bokeh, we can embed the charts on the web, and make a live
dashboard, and apps.
• Bokeh provides its own styling option and widgets for the charts.
• This is the advantage of embedding the bokeh charts on and website using
Flask or Django.
Benefits of Bokeh
• Bokeh allows you to build complex statistical plots quickly and through simple
commands
• Bokeh provides you output in various medium like html, notebook and server
• We can also embed Bokeh visualization to flask and django app
• Bokeh can transform visualization written in other libraries like matplotlib, seaborn,
ggplot
• Bokeh has flexibility for applying interaction, layouts and different styling option to
visualization
Challenges of Bokeh
• In the future, we have a lot of development in Bokeh
• Code is reusable for future enhancement
• Less visualization options when compared to D3.js
Different forms
Steps to visualize a plot
1. Import the library and functions/ methods
2. Prepare the data
3. Set the output mode (Notebook, Web Browser, or Server)
4. Create a chart with a styling option (if required)
5. Visualize the chart
Bokeh Interface
• Provides a simple interface for users like domain experts.
• Layered approach and offers programming interfaces to different uses.
• Two interfaces.
• Bokeh. plotting
• Bokeh. models
The bokeh.plotting interface
• It is a primary interface.
• It focuses on relating glyphs to data.
• It automatically assembles plots with default elements such as axes, grids,
and tools.
• Figure() function is core of bokeh.plotting interface.
• This function adding different kinds of glyphs to plot
• It gives axes,grids,tools
The bokeh.model interface
• This module is a low-level interface.
• It provides a great deal of flexibility to the application developer in developing
visualizations.
• A Bokeh plot results in an object containing visual and data aspects of a scene
which is used by the BokehJS library.
• The low-level objects that comprise a Bokeh scene graph are called Models.
Basic types of plots
• Line plot:The line() method of Figure object adds a line glyph to the
Bokeh figure. It needs x and y parameters as data arrays for showing their
linear relationship.
• Bar plot:The figure object has two different methods for constructing bar
plot
• Hbar() Horizontal across plot width()
• Parameters height,right,left
Basic types of plots
• Vbar() shows vertical plot height
Parameters: width,top,bottom
• Patch plot:A plot which shades a region of space in a specific color to
show a region or a group having similar properties is termed as a patch
plot in Bokeh.
• Figure object has patch() and patches() methods for this purpose.
• Parameters:X,y,size,marker,color
Types of constants
• Diamond • Asterisk
• DiamondCross • Circle
• CircleCross
• Hex
• CircleX
• InvertedTriangle
• Cross
• Square • Dash
• SquareCross • Triangle
• SquareX • X
Plotting area plots