Interactive Visualization Libraries
Interactive Visualization Libraries
By
Veer Pal Singh
1. Bokeh Library
2. Pygal Library
3. Altair Library
4. Holoview Library
5. Plotly Library
What is Data Visualization?
Data visualization is a scientific method of finding out the patterns, anomalies, and outliers in the
data. It is a method that is used to create the graphs and plots which helps in finding out the trend
in the data because it makes data simpler in terms of understanding by the human brain and we
identify trends with naked eyes.
Interactive visualization is the use of data analysis software to manipulate and explore graphical
representations of data. It is an evolution of the concept of "dataviz" (data visualization) based on
the incorporation of interaction tools.
As such, interactive data visualization, using of the tools and processes of interactive libraries, pro-
duces a visual representation of data which can be explored and analyzed directly within the visuali-
zation itself. This interaction can help uncover insights which lead to better, data-driven decisions.
Representing data graphically and interactively in the form of graphs, charts, and maps helps users
quickly spot trends and assess the status of underlying patterns. Allowing direct interaction helps
users dig deeper to identify patterns and find new relationships in their data.
Content
• BOKEH LIBRARY
• PYGAL LIBRARY
• ALTAIR LIBRARY
• HOLOVIEWS LIBRARY
• PLOTLY LIBRARY
BOKEH LIBRARY
What is Bokeh?
Bokeh is an interactive visualization library in python. The best feature which bokeh provides is high-
ly interactive graphs and plots that target modern web browsers for presentations. Bokeh helps us to
make elegant, and concise charts with a wide range of various charts.
Bokeh primarily focuses on converting the data source into JSON format which then uses as input for
BokehJS. Some of the best features of Bokeh are:
• Flexibility: Bokeh provides simple charts and customs charts too for complex use-cases.
• Productivity: Bokeh has an easily compatible nature and can work with Pandas and Jupyter note-
books.
• Styling: We have control of our chart and we can easily modify the charts by using custom Javas-
cript.
• Open source: Bokeh provide a large number of examples and idea to start with and it is distribut-
ed under Berkeley Source Distribution (BSD) license. With bokeh, we can easily visualize large
data and create different charts in an attractive and elegant manner.
There are plenty of visualization libraries why do we need to use bokeh only? Let’s see why.
We can use the bokeh library to embed the charts on the web page. With bokeh, we can embed the
charts on the web, 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.
• kind what type of chart do you want to plot? Currently, pandas_bokeh supports the following
chart types: line, point, step, scatter, bar, histogram, area, pie and map.
• xlabel and ylabel The label of the x-axis and y-axis relatively
Pygal is an open-source python library that not only creates highly interactive plots but also creates
SVG images of the graphs/plots so that we can use it and customize it accordingly. Pygal is highly
customizable and creates graphs with a few lines of code.
Pygal creates a variety of plots like a bar, area, histogram, line, etc and due to the high scalability
of the images of the plot downloaded as SVG, we will have good quality images that can be embed-
ded into different projects, websites, etc. SOURCE. Therefore, not only does the pygal library offer
multiple charting options beyond what you consider standard charts suc as bar charts, line charts,
and pie graphs, but it also includes a world map, funnel charts, radar charts, and box plots, to name
just a few.
Let us examine the relationship between Petal Length & Petal Width by plotting a
Scatter Chart.
Let's go back to iris dataset to see the distribution of both Petal Length & Petal
Width at the same Histogram Chart.
ALTAIR LIBRARY
What is Altair library?
Altair is a declarative statistical visualization library for Python, based on Vega and Ve-
ga-Lite, and the source is available on GitHub. With Altair, you can spend more time
understanding your data and its meaning.
Altair offers a comprehensive suite of data visualization software suitable for enterprise
deployment. Business users, engineers, and analysts can connect to virtually any data
source and build data monitoring, analysis, and reporting applications without writing a
single line of code.
Image result for altair library This chart is created with Python Data Visualization library
Altair. Altair is a declarative statistical visualization library for Python, based on Vega
and Vega-Lite. Altair offers a powerful and concise visualization grammar that enables
you to build a wide range of statistical visualizations quickly
How about the relationship between 'body_mass_g' & 'flipper_length_mm'?
image.png
What is HoloViews?
HoloViews allows you to collect and annotate your data in a way that reveals it naturally, with a
minimum of effort needed for you to see your data as it actually is. HoloViews is not a plotting li-
brary -- it connects your data to plotting code implemented in other packages, such as matplotlib or
Bokeh. HoloViews is also not primarily a mass storage or archival data format like HDF5 -- it is de-
signed to package your data to make it maximally visualizable and viewable interactively.
If you supply just enough additional information to the data of interest, HoloViews allows you to
store, index, slice, analyze, reduce, compose, display, and animate your data as naturally as possi-
ble. HoloViews makes your numerical data come alive, revealing itself easily and without extensive
coding SOURCE.
Important Information
Holoviews maintains metadata about your plot and it does not do any plotting by itself. It just or-
ganizes metadata about how to plot data and uses it's underlying back-end library like bokeh, mat-
plotlib or plotly to actually plot data.
Let us first remember what Bokeh gives us.
We are plotting the scatter plot below to show the relationship between alcohol and malic_acid
values in wine. We can see that just one line of code is enough to create a simple interactive
graph. We need to pass the first argument as a dataframe that maintains data and then kdims
and vdims to represent x and y of a graph.
Let us create our first basic chart by playing with fundamental parameters.
Sometimes we need to separate out the glyphs by species. To do this, we can do a
groupby operation on the Element. That's right, we can do groupby operations on
graphical elements!
Sometimes we may be interested with grouping species and laying the plots out next to
each other, creating a layout. We can use the layout() method do to this.
If we may wish to split each species at the same chart, we need to use overlay.
We can use .opts() to add tooltips where we can hover and get additional infor-
mation from the vdims.
Box plots are made using hv.BoxWhisker elements. If multiple key dimensions are
specified, nested categorical axes are automatically set up.
We need to use hv.Scatter() to generate strip plots. When we specify the jitter kwargs,
we specify the width of the jitter.
Note that nested categorical axes are currently (as of June 10, 2021) only supported
for box, violin, and bar plots, as per the docs, but will eventually be supported for many
more plot types, including Scatter, which are used to generate strip plots.
When making a histogram, the values of the bin edges and counts must be com-
puted beforehand using np.histogram().
Empirical Cumulative Distribution Functions (ECDFs) are very important plots for visualizing how data are distributed.
PLOTLY LIBRARY
Plotly Express is a new Python visualization library that acts as a wrapper for Plotly, ex-
posing a simple syntax for complex charts. It was inspired by Seaborn and ggplot2 and
was specifically designed to have a terse, consistent, and easy-to-learn API: with a sin-
gle import, you can make richly interactive plots with faceting, maps, animations, and
trendlines in a single function call.
Plotly Express includes over 30 functions for creating various types of figures. The API
for these functions was carefully designed to be as consistent and easy to learn as pos-
sible, allowing you to easily switch from a scatter plot to a bar chart to a histogram to a
sunburst chart during a data exploration session.