Jupyter Notebook is used for data visualization, exploration and analysis. Voila is a Python package that allows you to convert Jupyter Notebooks into interactive web applications and we can create interactive web dashboards in it without modify any code. This means you can share your analysis with anyone even if they don't have any Python knowledge. In this article you’ll learn how to convert a Jupyter Notebook into interactive dashboard using Voila
Creating an Interactive Dashboard with Voila
Here is the step-by-step guide to creating an Interactive Dashboard from Jupyter Notebook with Voila:
Step1: Install Voila
Before you start. You need to install voila. You can do this directly from your Jupyter Notebook or from the command line using pip:
pip install voila
Step 2: Create file in Jupyter Notebook
Now open Jupyter Notebook and create a new file. This is where you’ll write the code that powers your dashboard. Start by importing the required libraries like numpy, pandas and plotly.
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objs as go
import plotly.figure_factory as ff
import warnings
warnings.filterwarnings("ignore")
from IPython.core.display import display, HTML
from IPython.display import display as ipy_display
Use HTML tags to add headings and descriptions to your dashboard. For example:
display(HTML('<h1 style="text-align:center;">Visualization for Voila Dashboard</h1>'))
display(HTML('<p style="text-align:center;"><strong>This is a sample dashboard created with Jupyter Notebook & Voila.</strong></p>'))
Output:

Now that we've set up our notebook and added some basic headings let's load our dataset and take a look at the first few rows. We'll use the pandas library, which makes it super easy to read data files and work with tables.
reviews = pd.read_csv("/content/winequality-red.csv", index_col=0)
reviews.head()
Output:

Step 3: Visualize Data with Plotly
Use Plotly to create interactive visualizations. Here are examples of different types of plots:
Scatter Plot
We will create a scatter plot to visualize the relationship between the 'Alchol' and 'Wine Quality' columns of a DataFrame named 'reviews' using an interactive scatter plot.
fig = px.scatter(reviews, x='alcohol', y='quality',
title='Alcohol Content vs. Wine Quality',
labels={'alcohol': 'Alcohol (%)', 'quality': 'Wine Quality'},
color='quality')
ipy_display(fig)
Output:

2D Histogram Contour Plot
It consists of a 2D histogram contour plot and a scatter plot showcasing a combination of 2D histogram contour plot and a scatter plot to visualize the distribution and relationship between the 'Alcohol' and 'pH' columns of a DataFrame named 'reviews'.
fig = px.histogram(reviews, x='quality', nbins=10,
title='Distribution of Wine Quality Ratings',
labels={'quality': 'Wine Quality'})
ipy_display(fig)
Output:

The above plot is a 2D histogram contour showing that most alcohol vs pH data points are concentrated around 9.5–10 alcohol and 3.2–3.4 pH.
3D Surface Plot
It processes and filters data from a DataFrame named 'reviews', transforms it and generates an interactive 3D surface plot representing the relationship between 'points' and 'price'.
df = reviews.assign(n=0).groupby(['citric acid', 'pH'])['n'].count().reset_index()
df = df[df['pH'] < 4.5]
z_data = df.pivot(index='pH', columns='citric acid', values='n').fillna(0).values.tolist()
fig = go.Figure(data=[go.Surface(z=z_data)])
fig.update_layout(title='3D Surface Plot of Citric Acid and pH')
ipy_display(fig)
Output:

This plot shows a 3D surface of citric acid and pH indicate high variability in z-values at low citric acid and pH levels.
Step 4: Deploy on a Server
- Save your Jupyter Notebook containing your dashboard.
- Open terminal or command prompt and use the
cdcommand to navigate to the directory where your Jupyter Notebook is saved. - Run the following command in the terminal
Voila Voila_Dashboard.ipynb
Then it will automatically launch on your local host in your browser.