A chart can communicate a business insight in 2 seconds that would take 200 rows of numbers to explain. Matplotlib is Python's foundational plotting library, and Seaborn builds on top of it with more attractive, statistically-aware charts.
pip install matplotlib seaborn
import matplotlib.pyplot as plt
import seaborn as snsAll charts in this module use a sample dataset from Samantus Institute's own monthly revenue, course enrollments, and student performance records.
Line charts are best for showing trends over time — perfect for tracking revenue, growth, or performance month over month.
months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"]
revenue = [180000,195000,210000,205000,230000,250000,265000,280000]
plt.plot(months, revenue, marker="o", color="orange")
plt.title("Monthly Revenue Trend")
plt.xlabel("Month"); plt.ylabel("Revenue (Rs.)")
plt.show()Bar charts compare quantities across categories — ideal for comparing enrollment counts across different courses.
courses = ["SEO","Google Ads","Meta Ads","Web Design","AI Tools"]
enrollments = [45, 38, 42, 28, 55]
plt.bar(courses, enrollments, color=["navy","orange","blue","green","purple"])
plt.title("Student Enrollments by Course")
plt.show()Pie charts show proportions of a whole — best used with a small number of categories (5 or fewer).
plt.pie(enrollments, labels=courses, autopct="%1.1f%%")
plt.title("Course Enrollment Share (%)")
plt.show()Histograms show the distribution of a single numeric variable — how values are spread across ranges.
plt.hist(marks, bins=15, color="steelblue", edgecolor="white")
plt.title("Distribution of Student Marks")
plt.xlabel("Marks"); plt.ylabel("Number of Students")
plt.show()Scatter plots reveal the relationship between two numeric variables — used to spot correlations and patterns.
plt.scatter(ages, study_hours, color="orange", edgecolor="navy")
plt.title("Age vs Weekly Study Hours")
plt.xlabel("Age"); plt.ylabel("Study Hours per Week")
plt.show()Heatmaps visualize a matrix of values using color intensity — most commonly used to display correlation between multiple numeric variables at once.
corr = df[["Study_Hours","Attendance","Marks","Assignments"]].corr()
sns.heatmap(corr, annot=True, cmap="Oranges")
plt.title("Correlation Heatmap")
plt.show()Box plots show the spread, median, and outliers of a numeric variable, often split by category — extremely useful for spotting unusual data points.
sns.boxplot(data=df, x="Course", y="Score")
plt.title("Score Distribution & Outliers by Course")
plt.show()A pair plot shows scatter plots between every combination of numeric columns at once — a fast way to spot multiple relationships in one view.
sns.pairplot(df, hue="Course")
plt.show()| Goal | Best Chart |
|---|---|
| Show a trend over time | Line Chart |
| Compare categories | Bar Chart |
| Show proportion of a whole (few categories) | Pie Chart |
| Show distribution of one variable | Histogram |
| Show relationship between 2 variables | Scatter Plot |
| Show relationships between many variables at once | Heatmap / Pair Plot |
| Show spread & outliers by category | Box Plot |
Basic (5 Questions)
1. Create a line chart showing your own 6-month sample expense data.
2. Create a bar chart comparing marks of 5 students.
3. Create a pie chart showing the % split of your daily activities (study, work, rest, etc.).
4. Create a histogram of 50 random exam scores.
5. Create a scatter plot of hours studied vs marks scored for 15 students.
Intermediate (5 Questions)
1. Add titles, axis labels, and a legend to any 2 charts from the Basic section.
2. Create a heatmap showing the correlation between 4 numeric columns of a sample dataset.
3. Create a box plot comparing exam scores across 3 different classes/sections.
4. Combine a bar chart and line chart on the same figure using two y-axes (advanced formatting).
5. Create a pair plot for a 3-column numeric dataset and describe one insight from it.
Advanced (5 Questions)
1. Build a complete 'Monthly Sales Dashboard' with 3 charts: line (trend), bar (by category), and pie (share).
2. Create a heatmap-based correlation analysis for a real dataset with at least 5 numeric columns.
3. Build a box plot comparing student performance across 4+ courses and write a 3-sentence interpretation.
4. Create a scatter plot with a trend line (using seaborn's regplot) and interpret the relationship.
5. Design a full one-page visual report combining 4 different chart types for a sample business dataset of your choice.
Q1. Which chart is best for showing a trend over time?
Q2. Which chart should be avoided with more than 6 categories?
Q3. Which chart shows the distribution of one numeric variable?
Q4. Which chart is best for spotting outliers?
Q5. Which library builds on top of Matplotlib with more advanced statistical charts?
Assignment: Institute Performance Visual Report
Expected Output: A complete 4-chart visual performance report with clear titles, labels, and a written business interpretation.
Use this space to write down key points, doubts, and your own examples from today's session.