Open In App

Interactive Dashboard from Jupyter with Voila

Last Updated : 15 Apr, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

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.

Python
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:

Python
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:

Screenshot-2025-04-10-123708

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.

Python
reviews = pd.read_csv("/content/winequality-red.csv", index_col=0)
reviews.head()

Output:

Screenshot-2025-04-10-121639
Wine Quality Dataset

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.

Python
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:

Screenshot-2025-04-10-122222
Scatter plot between wine Quality and Alcohol

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'.

Python
fig = px.histogram(reviews, x='quality', nbins=10,
                   title='Distribution of Wine Quality Ratings',
                   labels={'quality': 'Wine Quality'})
ipy_display(fig)

Output:

Screenshot-2025-04-10-122157
2D plot between Alcohol and pH

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'.

Python
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:

Screenshot-2025-04-10-122305
3d surface plot of citric acid and pH

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

  1. Save your Jupyter Notebook containing your dashboard.
  2. Open terminal or command prompt and use the cd command to navigate to the directory where your Jupyter Notebook is saved.
  3. Run the following command in the terminal

Voila Voila_Dashboard.ipynb

Then it will automatically launch on your local host in your browser.


Next Article

Similar Reads