📘 SERIES · CHAPTER 67🐍 PYTHON

Python Data Visualisation for Data Analysts — Matplotlib, Seaborn & Plotly Complete Guide

Three libraries, one workflow. This chapter teaches you when to use Matplotlib, Seaborn and Plotly, gives you copy-paste code for every common chart type, and shows you the EDA visualisation pattern that experienced analysts follow on every new dataset.

⏱ 22 min read📅 September 2026✍ EVIKA ACADEMY, Noida

Choosing the Right Library: Matplotlib vs Seaborn vs Plotly

The most common question Python beginners ask is which visualisation library to learn first. The answer is all three — but for different purposes. They are not competitors; they are layers of a stack that professional analysts use together.

Matplotlib
The foundation

Full control over every pixel. Use when you need custom layouts, subplots, or chart types no other library provides.

Best for: Custom figures, publication charts, multi-panel layouts
Seaborn
Statistical charts

Built on Matplotlib, adds beautiful defaults and statistical chart types (violin, heatmap, pairplot) in fewer lines of code.

Best for: EDA, statistical distribution analysis, correlation matrices
Plotly
Interactive charts

Creates interactive charts with hover tooltips, zoom and pan — ideal for dashboards and sharing with stakeholders who need to explore the data.

Best for: Stakeholder dashboards, Jupyter notebooks shared externally
Install all three:
pip install matplotlib seaborn plotly pandas

Matplotlib — Core Charts Every Analyst Needs

Matplotlib uses a figure/axes architecture. Every chart has a fig (the canvas) and one or more ax (the plot area). Always create them explicitly — it avoids confusing behaviour when building multi-panel charts.

Line Chart — Trend Over Time

# Line chart with annotations import matplotlib.pyplot as plt import pandas as pd df = pd.read_csv('monthly_revenue.csv', parse_dates=['month']) fig, ax = plt.subplots(figsize=(10, 5)) ax.plot(df['month'], df['revenue'], color='#1d4ed8', linewidth=2.5, marker='o', markersize=5) # Annotate a key event ax.axvline(x=pd.Timestamp('2026-07-01'), color='#ef4444', linestyle='--', alpha=0.7) ax.text(pd.Timestamp('2026-07-01'), ax.get_ylim()[1] * 0.95, 'New pricing launched', color='#ef4444', fontsize=9) ax.set_title('Monthly Revenue — FY2026', fontsize=14, fontweight='bold', pad=12) ax.set_xlabel('Month') ax.set_ylabel('Revenue (₹)') ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f'₹{x/1e5:.1f}L')) ax.spines[['top', 'right']].set_visible(False) plt.tight_layout() plt.savefig('revenue_trend.png', dpi=150, bbox_inches='tight') plt.show()

Horizontal Bar Chart — Category Comparison

# Sorted horizontal bar — best for comparing categories categories = ['Email', 'Paid Search', 'Organic', 'Social', 'Referral'] values = [42, 31, 18, 6, 3] # Sort descending before plotting pairs = sorted(zip(values, categories)) values_s, cats_s = zip(*pairs) fig, ax = plt.subplots(figsize=(8, 4)) bars = ax.barh(cats_s, values_s, color=['#1d4ed8' if v == max(values_s) else '#93c5fd' for v in values_s]) # Add value labels inside bars for bar, val in zip(bars, values_s): ax.text(val - 1, bar.get_y() + bar.get_height()/2, f'{val}%', va='center', ha='right', color='white', fontweight='bold') ax.set_title('Revenue by Channel (%)', fontweight='bold') ax.set_xlabel('Revenue Share (%)') ax.spines[['top', 'right', 'left']].set_visible(False) plt.tight_layout() plt.show()

Multi-Panel Subplots

# 2×2 dashboard layout fig, axes = plt.subplots(2, 2, figsize=(12, 8)) fig.suptitle('Q3 2026 Performance Overview', fontsize=16, fontweight='bold') axes[0, 0].plot(dates, revenue) # top-left axes[0, 1].bar(channels, orders) # top-right axes[1, 0].scatter(spend, roas) # bottom-left axes[1, 1].hist(order_values, bins=30) # bottom-right plt.tight_layout() plt.show()

Seaborn — Statistical Charts for EDA

Seaborn shines during exploratory data analysis. It automatically computes and displays statistical relationships — distributions, correlations, category comparisons — with far less code than raw Matplotlib. Always call sns.set_theme() at the start of a notebook to activate clean defaults.

Correlation Heatmap

import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style='whitegrid', palette='muted') # Compute correlation matrix on numeric columns only corr = df.select_dtypes(include='number').corr() fig, ax = plt.subplots(figsize=(9, 7)) sns.heatmap(corr, annot=True, fmt='.2f', cmap='coolwarm', center=0, square=True, linewidths=0.5, cbar_kws={"shrink": 0.8}, ax=ax) ax.set_title('Feature Correlation Matrix', fontweight='bold', pad=12) plt.tight_layout() plt.show()

Distribution Plot (Histogram + KDE)

# Distribution with kernel density estimate fig, axes = plt.subplots(1, 2, figsize=(12, 4)) sns.histplot(df['order_value'], kde=True, bins=40, color='#1d4ed8', ax=axes[0]) axes[0].set_title('Order Value Distribution') # Box plot to compare groups sns.boxplot(data=df, x='channel', y='order_value', palette='Blues_r', ax=axes[1]) axes[1].set_title('Order Value by Channel') axes[1].tick_params(axis='x', rotation=30) plt.tight_layout() plt.show()

Pairplot — Full EDA in One Call

# Scatter matrix of all numeric pairs, coloured by category sns.pairplot(df, hue='segment', # colour by a categorical column diag_kind='kde', # KDE on diagonal instead of histogram plot_kws={"alpha": 0.6}, palette='tab10') plt.suptitle('Feature Relationships by Segment', y=1.02, fontweight='bold') plt.show()
Tip: Pairplot slows down on large datasets. Sample first: df.sample(2000) for datasets over 100K rows.

Plotly — Interactive Charts for Stakeholder Dashboards

Plotly creates interactive HTML charts — stakeholders can hover over data points, zoom in, toggle series, and explore on their own. This is a significant credibility boost when sharing analysis: instead of a static image, you hand over a chart they can interrogate.

Interactive Line Chart with Plotly Express

import plotly.express as px import pandas as pd fig = px.line(df, x='date', y='revenue', color='channel', title='Daily Revenue by Channel', labels={"revenue": "Revenue (₹)", "date": "Date"}, template='plotly_white') fig.update_traces(line_width=2) fig.update_layout(hovermode='x unified', legend=dict(orientation='h', yanchor='bottom', y=1.02)) fig.write_html('revenue_chart.html') # share as HTML file fig.show()

Funnel Chart — Conversion Analysis

import plotly.graph_objects as go stages = ['Visited', 'Added to Cart', 'Checkout', 'Payment', 'Purchased'] values = [10000, 4200, 2800, 1900, 1450] fig = go.Figure(go.Funnel( y=stages, x=values, textinfo='value+percent initial', marker_color=['#1d4ed8', '#3b82f6', '#60a5fa', '#93c5fd', '#22c55e'] )) fig.update_layout(title='Checkout Funnel — Sept 2026', template='plotly_white') fig.show()

Scatter Plot with Trendline

fig = px.scatter(df, x='ad_spend', y='revenue', color='channel', size='sessions', # bubble size = traffic volume hover_data=['campaign_name'], trendline='ols', # OLS regression line title='Ad Spend vs Revenue by Channel', template='plotly_white') fig.show()

The 5-Step EDA Visualisation Workflow

Experienced analysts follow the same visualisation sequence on every new dataset. This order ensures you catch data quality issues before drawing any conclusions.

01
Shape check
print(df.shape, df.dtypes, df.isnull().sum())
Why first: Know your dimensions, column types, and missing value counts before plotting anything.
02
Univariate distributions
df.hist(bins=30, figsize=(14, 8)); plt.tight_layout()
Why first: Spot skew, outliers, and unexpected value ranges in every numeric column at once.
03
Categorical value counts
for col in df.select_dtypes('object'): df[col].value_counts().head(10).plot(kind='barh')
Why first: Find rare categories, data entry errors, and high-cardinality columns that need encoding.
04
Correlation heatmap
sns.heatmap(df.corr(numeric_only=True), annot=True, cmap='coolwarm', center=0)
Why first: Identify features that move together — reveals multicollinearity and potential predictors.
05
Time series (if date column exists)
df.set_index('date')['metric'].resample('W').sum().plot()
Why first: Seasonality, anomalies, and trend direction emerge from the weekly aggregated view.

6 Python Visualisation Mistakes That Undermine Your Analysis

Y-axis not starting at zero
Fix: For bar charts, always start at zero. Truncated y-axes exaggerate differences. For line charts, it is acceptable to start above zero — but label it clearly.
Using default Matplotlib colours
Fix: Default colours are low-contrast and inaccessible. Use a named palette: seaborn "muted" or "colorblind" for accessibility, or define your own hex colours.
Missing chart titles and axis labels
Fix: Always set title, xlabel, ylabel. A chart without labels forces the viewer to ask questions instead of absorbing the finding.
Plotting all data without sampling
Fix: Scatter plots with 500K points render as a solid blob. Sample 5,000–10,000 representative rows or use hexbin/2D histogram instead.
Pie charts with many slices
Fix: Humans cannot compare angular areas accurately. Use a sorted bar chart instead. Reserve pie charts for 3–4 slices maximum where proportions are clearly different.
Not removing chart junk
Fix: Remove top and right spines (ax.spines[['top','right']].set_visible(False)), reduce gridlines, and avoid 3D charts — they always distort perception.

Saving & Sharing Charts Professionally

# Matplotlib — save high-resolution PNG for reports plt.savefig('chart.png', dpi=150, bbox_inches='tight', facecolor='white') # white background for Slack/email # Matplotlib — save as SVG for PowerPoint (scalable, no blur) plt.savefig('chart.svg', format='svg', bbox_inches='tight') # Plotly — export static PNG (requires kaleido) # pip install kaleido fig.write_image('chart.png', scale=2) # Plotly — export interactive HTML (best for sharing) fig.write_html('dashboard.html', include_plotlyjs='cdn') # small file, loads from CDN
Best practice: Share Plotly charts as HTML files via Google Drive or Notion. They are self-contained, interactive, and load instantly — far better than sending a PNG that stakeholders cannot explore.

Learn Python Data Visualisation at EVIKA ACADEMY

Our Python for Data Analytics course in Noida covers Matplotlib, Seaborn and Plotly with real datasets and portfolio-ready projects. Online & offline classes at Sector 51.

📱 Book Free Demo Class →

Frequently Asked Questions

Which Python library is best for data visualisation?

Use all three for different purposes: Matplotlib for full control and custom layouts, Seaborn for statistical charts with fewer lines of code, and Plotly for interactive charts you share with stakeholders. Most working data analysts use Seaborn for EDA and Plotly for deliverables.

Should I learn Matplotlib or Seaborn first?

Learn Matplotlib basics first — understanding figures, axes and the object-oriented interface makes Seaborn much easier because Seaborn builds on Matplotlib. Spend one week on Matplotlib essentials, then move to Seaborn for statistical charts.

What is the difference between Seaborn and Plotly?

Seaborn creates static charts optimised for statistical analysis and EDA, with minimal code. Plotly creates interactive charts — users can hover, zoom, and filter — making it better for stakeholder dashboards and shared deliverables.

How do data analysts use Python for visualisation in real jobs?

Working analysts typically use Seaborn and Matplotlib in Jupyter notebooks for EDA, Plotly for interactive reports shared with business teams, and either matplotlib.savefig or Plotly HTML export for final deliverables. Power BI or Tableau is often used for recurring dashboards.

Where can I learn Python data visualisation in Noida?

EVIKA ACADEMY in Noida Sector 51 offers a Python for Data Analytics course covering Matplotlib, Seaborn and Plotly with hands-on projects. Online and offline classes are available. WhatsApp +91-8081035456 to book a free demo class.

🎓 Free Demo Class — Online & Offline · Noida Sector 51