# 5 Interactive Data Visualization tools for Python applications

At one point, when you play with data, generating graphs on a Jupyter Notebook is no longer enough.

Besides, my 300-dimensional vectors delivered in JSON format were not as sexy in the eyes of my colleagues as they were in mine. Unfortunate.

But! There are Python tools to generate graphs on-the-fly on your application. Benefits:

• Allow data edition on client-side by the user and automatically update the graph(s) accordingly.
• Make them beautifully interactive
• Bring with each figure a toolbox for the user to zoom, resize, move axes, … and reset all these changes.

## 1982: Maple and Matlab

It’s hard to talk about data processing and visualization without evoking at least Matlab.

Maple was first released in 1982 and Matlab in 1984.

They both are:

• Private software
• Providing a programming language to manipulate numbers, matrix and create functions
• Display data using complex graphs

Matlab can be interfaced with C, C++, Java and Fortran while Maple was inspired by Algol (even though they were written in C and Java).

## 2003: Matplotlib

Matplotlib was initially released in 2003 by Michael Droettboom, et al.

That’s probably the first one you heard of when looking for a visualization tool in Python.

Matplotlib is designed to be as usable as MATLAB, with the ability to use Python, and the advantage of being free and open-source.

In the code below, we plot a simple histogram:

`import matplotlib matplotlib.use("TkAgg") from matplotlib import pyplot as plt import pandas as pd histogram = {'10': 6, '7': 2, '6': 3, '9': 2, '8': 7,              '5': 3, '4': 0, '3': 0, '1': 1, '2': 0} serie = pd.Series(histogram) serie.plot.hist(grid=True, bins=20, rwidth=0.9, color='#607c8e') plt.title(f"Histogram Rating") plt.xlabel('Rate given') plt.ylabel('Occurrence') plt.grid(axis='y', alpha=0.75)`

Did you notice the line `matplotlib.use("TkAgg")`? It is optional but allows you to specify a backend. Matplotlib works with a number of user interface toolkits : wxpython, tkinter, qt4, gtk, macosx, …

By the way, the same backend could be summoned from IPython using `%matplotlib tk`. If you are curious about the differences between IPython and Jupyter or want to dig into Python data science environments and computational notebooks, I recommend this great article by DataCamp.

The backend is required by matplotlib to support multiple output targets, hence multiple use cases. Target examples:

• Inside Jupyter notebooks
• From the interactive shell
• Embed in graphical user interfaces
• Embed in web applications

In order to support features like interactive panning and zooming of figures, Matplotlib provides ways to handle callbacks on Key Press, Mouse Events, etc.

## 2013: Bokeh

Bokeh is an interactive visualization library for Python, first released in the public in April, 2013.

Bokeh enables beautiful and meaningful visual presentation of data in modern web browsers. You can quickly and easily create interactive plots, dashboards, and data applications.

Bokeh also delivers high-performance interactivity for large or streamed datasets.

Bokeh is fiscally a sponsored project of NumFOCUS, a nonprofit dedicated to supporting the open-source scientific computing community.

#### Trivia

Bokeh refers to the artistic background blur of a photograph. The word comes from the Japanese “boke”, but with this spelling, people were more likely to pronounce it as “coke”… So it was coined in English as “bokeh”.

## 2015: Dash, by Plot.ly

Dash started as public proof-of-concept on GitHub in 2015.

Built on top of Plotly.js, React, and Flask, Dash ties modern UI elements like dropdowns, sliders, and graphs to your analytical Python code.

Best features :

## 2017: HoloViews

HoloViews was first released on GitHub & PyPI the 17th March 2017.

HoloViews is built on top of Bokeh server.

Their motto: Stop plotting your data – annotate your data and let it visualize itself.

With HoloViews, you can express what you want to do in very few lines of code, letting you focus on what you are trying to explore and convey, not on the process of plotting.