Data Visualization & Storytelling
Matplotlib | Seaborn | Plotly
1. Principles of dashboard design
2. Visualization with Matplotlib
3. Seaborn for Statistical Visualization
4. Interactive Visualization Using Plotly
5. Visualization-driven Insight Generation
A Presentation by: Prapty Parajuli
-080bct0
1 Principles of Effective Visualization
Dashboard design | Chart selection | Visual clarity
Principles of Effective Visualization & Dashboard Design
Purpose First Right Chart Type Minimize Clutter
Every chart should answer a Match chart type to data intent: Remove unnecessary gridlines,
specific question. Define the comparisons → bar, trends → borders, and redundant labels. A
insight before choosing the chart line, relationships → scatter, high data-ink ratio means more
type. Avoid decorative visuals distributions → histogram. of the visual is dedicated to
that add no analytical value. Wrong chart type misleads. actual data.
Consistency Hierarchy & Layout Interactivity
Use uniform colors, fonts, and Place the most critical visual Good dashboards allow filtering,
axis scales across all charts. top-left. Group related charts drill-down, and tooltips without
Inconsistency creates confusion together to guide the viewer's overwhelming the user.
and leads to misinterpretation. story through the dashboard. Interactivity should reveal detail,
not add complexity.
2 Visualization with Matplotlib
Line | Bar | Histogram | Scatter | Subplots
Line Plot
Trends over continuous / sequential data
Key Points
⚬ Ideal for showing trends over time series or
sequential data.
⚬ Use markers for sparse data and smooth lines
for dense continuous data.
⚬ Multiple lines allow direct comparison across
categories or groups.
Python
import numpy as np
import [Link] as plt
x = [Link](1, 13)
sales = [Link]([120,135,150,170,160,180,200,195,210,230,220,250]}
[Link](x, sales, marker='o', color='steelblue', linewidth=2)
[Link]('Monthly Sales Trend')
[Link]('Month'); [Link]('Sales')
[Link](x)
[Link](True, linestyle='--', alpha=0.5)
plt.tight_layout()
[Link]()
Bar Chart
Comparing discrete categories
Key Points
⚬ Best for comparing values across discrete,
named categories.
⚬ Grouped bar charts allow side-by-side
comparison of sub-categories.
⚬ Use horizontal bars when category names are
long to avoid label overlap.
Python
import numpy as np
import [Link] as plt
categories = ['Electronics','Clothing','Food','Furniture','Toys']
revenue = [Link]([45000,32000,27000, 38000,21000])
[Link](categories, revenue, color='cornflowerblue',
edgecolor='black')
[Link]('Revenue by Category')
[Link]('Category')
[Link]('Revenue ($)')
plt.tight_layout()
[Link]()
Histogram
Matplotlib — Distribution of a continuous variable
Key Points
⚬ Visualizes the frequency distribution of a single
continuous variable.
⚬ Bin size controls detail — too few hides shape,
too many creates noise.
⚬ Overlapping histograms with transparency
(alpha) compare two distributions.
Python
import numpy as np
import [Link] as plt
[Link](42)
group_a = [Link](60, 10, 300)
group_b = [Link](75, 8, 300)
[Link](group_a, bins=20, alpha=0.6, label='Group A', color='steelblue')
[Link](group_b, bins=20, alpha=0.6, label='Group B', color='darkorange')
[Link]('Score Distribution: A vs B')
[Link]('Score'); [Link]('Frequency')
[Link]()
plt.tight_layout()
[Link]()
Scatter Plot
Matplotlib — Relationships between two numeric variables
Key Points
⚬ Reveals correlation between two continuous
numeric variables.
⚬ Color or size of points can encode a third
variable without extra charts.
⚬ Clusters and outliers in scatter plots often yield
the most valuable insights.
Python
import numpy as np
import [Link] as plt
[Link](42)
hours = [Link](1, 10, 100)
scores = hours * 8 + [Link](0,5,100)
[Link](hours, scores, color='darkorange', alpha=0.7, edgecolors='black')
[Link]('Hours Studied vs Exam Score')
[Link]('Hours Studied')
[Link]('Score')
plt.tight_layout()
[Link]()
Subplots
Multiple plots in a single figure
Key Points
⚬ Display multiple related plots in one figure for
efficient comparison.
⚬ Use [Link](rows, cols) to define grid
layout; share axes where needed.
⚬ Ideal for dashboards or reports where space is
limited and context switching is costly.
Python
import numpy as np
import [Link] as plt
[Link](1)
fig, axes = [Link](2, 2, figsize=(10,8))
axes[0,0].plot([Link]([Link](50)),vcolor='steelblue')
axes[0,0].set_title('Line Plot')
axes[0,1].bar(['A','B','C','D'],[Link](10,100,4),vcolor='salmon')
axes[0,1].set_title('Bar Chart')
axes[1,0].hist([Link](50,15,300),vbins=15, color='mediumpurple')
axes[1,0].set_title('Histogram')
axes[1,1].scatter([Link](50),[Link](50),vcolor='seagreen',alpha=0.7)
axes[1,1].set_title('Scatter Plot')
[Link]('2x2 Subplot Dashboard')
plt.tight_layout()
[Link]()
3 Seaborn for StatisticalVisualization
Boxplot | Pairplot | Heatmap
Box Plot
Distribution, spread, and outliers at a glance
Key Points
⚬ Displays median, interquartile range (IQR), and
outliers in one chart.
⚬ Whiskers extend to 1.5× IQR; any point beyond
is plotted as an outlier.
⚬ Comparing across groups makes it easy to spot
differences in spread and central tendency.
Python
import numpy as np, pandas as pd
import seaborn as sns
import [Link] as plt
[Link](42)
data = [Link]({'Score': [Link]([
[Link](70,10,100),
[Link](80,8,100),
[Link](65,12,100)]),
'Group': ['A']*100+['B']*100+['C']*100})
[Link](x='Group', y='Score', data=data, palette='Set2')
[Link]('Score Distribution by Group')
plt.tight_layout()
[Link]()
Pair Plot
Seaborn — All pairwise variable relationships in one grid
Key Points
⚬ Plots every pairwise combination of numeric
variables in a grid automatically.
⚬ Diagonal cells show each variable's own
distribution (KDE or histogram).
⚬ Coloring by a categorical variable reveals class
separation and clustering instantly.
Python
import numpy as np, pandas as pd
import seaborn as sns
import [Link] as plt
[Link](7)
df = [Link]({
'Study_Hours': [Link](1,10,120),
'Sleep_Hours': [Link](4,9,120),
'Score': [Link](70,15,120),
'Category': [Link](['Arts','Science','Commerce'], 120)
})
[Link](df, hue='Category', diag_kind='hist', palette='Set1')
[Link]('Pairplot by Student Category', y=1.02)
[Link]()
Heat Map
Matrix data visualized through color intensity
Key Points
⚬ Represents matrix data using color intensity;
warmer colors indicate higher values.
⚬ Commonly used for correlation matrices to
identify strongly related features at a glance.
⚬ Annotating cells with values adds precision
while color still guides visual attention.
Python
import numpy as np, pandas as pd
import seaborn as sns
import [Link] as plt
[Link](42)
df = [Link](
[Link](100, 5),
columns=['Sales', 'Profit', 'Ad_Spend', 'Returns', 'Satisfaction'])
[Link]([Link](), annot=True, fmt='.2f', cmap='coolwarm', linewidths=0.5)
[Link]('Feature Correlation Heatmap')
plt.tight_layout()
[Link]()
4 Interactive Visualization using Plotly
Plotly Express | Graph Objects | Dash
Interactive Visualization using Plotly
Zoom, Hover, Filter- all in the browser
Why use Plotly? Plotly Express
It creates fully interactive charts with zoom, pan, hover It is a high-level API that generates complex charts in just a
tooltips, and legend toggling directly in the browser or few lines of code. Best for quick exploratory visualization
Jupyter. Far more engaging than static charts. with clean, publication-ready defaults.
Graph Objects Dash Integration
They are low-level APIs offering full control over every Plotly is the core engine behind Dash, enabling fully
visual element: layout, axes, annotations, traces. Used when interactive web-based analytics apps without any JavaScript
Plotly Express lacks required customization. knowledge.
Plotly: Interactive Line Chart
Plotly Express - [Link]() with markers and color grouping
Python
import numpy as np, pandas as pd
import [Link] as px
[Link](42)
df = [Link]({
'Month': [Link]([Link](1, 13), 2),
'Sales': [Link]([[Link](100, 300, 12),[Link](80, 250, 12)]),
'Region': ['North']*12 + ['South']*12
})
fig = [Link](df, x='Month', y='Sales', color='Region',title='Interactive Monthly Sales by Region', markers=True)
[Link]()
Plotly: Interactive Bubble Chart
Plotly Express - [Link]() with size encoding
Python
import numpy as np, pandas as pd
import [Link] as px
[Link](0)
df = [Link]({
'Ad_Spend': [Link](500, 5000, 80),
'Revenue': [Link](1000, 20000, 80),
'Profit': [Link](200, 5000, 80),
'Category': [Link](
['Electronics','Clothing','Food'], 80)
})
fig = [Link](df, x='Ad_Spend', y='Revenue', size='Profit', color='Category', hover_data=['Profit'], title='Ad Spend vs Revenue (Bubble = Profit)')
[Link]()
5 Visualization Driven Insight
From charts to decisions
Visualization Driven Insight Generation
Turning visual patterns into actionable conclusions
01 Pattern Recognition 02 Outlier Detection 03 Correlation Insights
Visuals surface trends, seasonality, and Box plots and scatter plots immediately Heatmaps and pair plots reveal which
clusters far faster than scanning raw flag anomalies that statistical variables are strongly related, helping
tables. The human eye detects chart summaries like mean and std can mask prioritize features for modeling or
patterns in seconds. or miss entirely. business focus.
04 Storytelling with Data 05 Actionable Dashboards 06 Iterative Exploration
Sequence visuals intentionally: context Combine chart types to answer who, Begin with broad distributions, drill
→ finding → implication. Charts what, when, and why in one view. into group comparisons, and confirm
should guide the audience to a Every chart should drive a decision, not findings with statistical overlays or
conclusion. just display data. trend lines.
Summary
Charts should be chosen based on the question, not aesthetics.
Matplotlib provides full control; Seaborn adds statistical depth.
Plotly transforms static charts into interactive, explorable visuals.
Every visualization should lead to an insight or decision.
Design should for clarity: minimized clutter, maximized data-ink ratio.