A table full of numbers hides its own story. A chart reveals it instantly. That’s the entire idea behind data visualization with matplotlib and seaborn, and it’s the focus of Episode 19 in our machine learning series on the Intelevo YouTube channel.
In Episode 18, you learned how pandas organizes, merges, and summarizes data. Now, you’ll learn how to turn that organized data into pictures. Pictures speak faster than spreadsheets. They catch patterns your eyes would otherwise miss. And they make your analysis instantly shareable with anyone, technical or not.
Think about the last time someone handed you a spreadsheet with five hundred rows. Did you read every single row? Probably not. Instead, you likely skimmed a few, then asked someone to summarize it for you. That instinct explains exactly why visualization matters so much in real work. Charts do the summarizing visually, so nobody needs to scroll through raw numbers to find the point.
This article walks through every idea from the video, in the same order, with the same code. Read it alongside the video, or use it as a quick reference afterward. Either way, by the end, chart-making will feel simple, not scary.
Before diving into the concepts, let’s quickly cover setup, so you can follow along on your own machine.
Getting Started: Installing Matplotlib and Seaborn
Both libraries install in seconds through pip. First, open your terminal and run this command:
pip install matplotlib seaborn pandas
Once installation finishes, import them at the top of your script or notebook like this:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
That’s genuinely all the setup required. There are no configuration files and no complicated dependencies to manage. From here, every example in this article runs immediately, whether you work in Jupyter Notebook, Google Colab, or a plain Python script.
Why Data Visualization Matters More Than You Think
Picture a weather report. Now imagine it as a list of fifty city temperatures, written as plain numbers. You’d have to scan every single row to spot a pattern. Next, imagine the same data shown as a colored map instead. Warm regions glow in the south. Cool regions shade blue up north. Suddenly, you see the pattern in two seconds, not two minutes.
Both versions hold identical facts. However, only one version lets your brain process it instantly. That’s the power of visualization. It doesn’t add new information to your data. Instead, it changes the format so your brain can absorb it faster.
You already read charts like this every day. Weather apps, news graphics, fitness trackers, and stock market tickers all use the same core ideas you’re about to learn. Therefore, this episode isn’t introducing something foreign. It’s teaching you to build what you already understand as a viewer.
Three building blocks make this possible:
- Matplotlib – the foundational library that draws any chart exactly as instructed
- Seaborn – a layer on top of Matplotlib, built to work directly with DataFrames
- Choosing the right chart – matching your question to the correct chart type
Let’s take them one at a time.
Matplotlib: The Canvas Behind Every Chart
Every chart in Matplotlib begins with two components: a figure and an axes. Think of the figure as a blank canvas. The axes, meanwhile, is the actual surface where your data gets drawn. Once you separate these two ideas, everything else in Matplotlib becomes easier to follow.
Here’s the simplest possible chart:
import matplotlib.pyplot as plt
months = ["Jan", "Feb", "Mar"]
sales = [200, 350, 300]
plt.plot(months, sales)
plt.show()
# one line connects the dots
Notice how little code this takes. You pass two lists to plt.plot(), and Matplotlib connects the matching points into a line. Then, plt.show() displays the result. Nothing hidden, nothing magical — just a canvas and a pencil.
Labels Turn a Plot Into a Message
A chart without labels is a chart nobody trusts. Bars and lines mean nothing on their own. Consequently, always add a title and axis labels before sharing any chart with someone else.
plt.bar(months, sales, color="steelblue")
plt.title("Sales by Month")
plt.xlabel("Month")
plt.ylabel("Amount (₹)")
plt.show()
# now the chart explains itself
Think of labels as captions under a photograph. A photo without a caption leaves viewers guessing. Similarly, plt.title() tells your audience what the chart is about, while plt.xlabel() and plt.ylabel() explain what each axis represents. This one habit alone separates a professional chart from a random decoration.
A Few More Customizations Worth Knowing
Once labels feel comfortable, a handful of extra tweaks make your charts look noticeably more polished. For instance, figsize controls the overall size of your chart, while plt.legend() adds a key whenever you plot multiple series together.
plt.figure(figsize=(8, 4))
plt.plot(months, sales, label="This Year")
plt.plot(months, [180, 300, 260], label="Last Year")
plt.legend()
plt.show()
Notice how label inside plt.plot() connects directly to plt.legend(). Consequently, viewers can instantly tell which line represents which year, without any guesswork. Small touches like this build trust in your charts, especially when sharing results with a non-technical audience.
Seaborn: Charts That Already Understand Your DataFrame
Once you’re comfortable with Matplotlib, Seaborn feels like a natural next step. Instead of manually slicing columns from your data, Seaborn reads column names directly from a DataFrame. Better yet, it automatically colors different groups without any extra effort from you.
import seaborn as sns
sns.scatterplot(
data=df,
x="hours_studied",
y="score",
hue="class"
)
Look closely at this code. You’re not extracting arrays or looping through rows. Instead, you simply name your columns: which one is x, which one is y, and which one should split the colors. Seaborn handles the rest. The same DataFrame you built in Episode 18 plugs directly into this line, with zero conversion needed.
Histograms and Box Plots: Seeing the Shape of Data
Beyond relationships between two variables, Seaborn also helps you understand the shape of a single column. This step matters immensely before training any model, since outliers and skewed data can quietly ruin your results.
sns.histplot(data=df, x="score", bins=10)
# -> a bar per score range
sns.boxplot(data=df, x="class", y="score")
# -> middle, spread, and outliers
A histogram works like a show of hands for each score range — it tells you where most values cluster. A box plot, on the other hand, marks the typical range and flags any scores sitting far outside it. Don’t let the word “distribution” intimidate you, either. It simply means how spread out your numbers are.
Choosing the Right Chart for the Right Question
Here’s a mistake many beginners make: picking a chart because it looks impressive, not because it answers the question. Avoid that trap. Instead, match your question to the correct chart type every time.
| Your Question | Best Chart | Code |
|---|---|---|
| How do groups compare? | Bar chart | plt.bar() |
| How does it change over time? | Line chart | plt.plot() |
| How do two numbers relate? | Scatter plot | sns.scatterplot() |
| How spread out is one number? | Histogram / box plot | sns.histplot() |
This table alone solves ninety percent of chart-selection confusion. Whenever you’re unsure which chart to build, return to this list first. Ask yourself what question you’re really asking, and the right chart usually becomes obvious.
Visual EDA: One Line, Every Relationship at Once
In Episode 18, you learned .describe() as a quick first look at your data before modeling. Visual EDA (Exploratory Data Analysis) is simply the picture version of that same habit.
import seaborn as sns
sns.pairplot(df, hue="class")
# every numeric column,
# plotted against every other,
# one command
This single line plots every numeric column against every other numeric column, all at once. As a result, patterns and outliers surface before you’ve trained a single model. DataFrames hold your data, groupby summarizes it, and pairplot draws every relationship in one glance. No serious machine learning project skips this step, because pictures catch what raw tables hide.
Matplotlib vs Seaborn: A Quick Comparison
By now, you might wonder when to reach for Matplotlib versus Seaborn. Here’s a simple side-by-side to settle that question.
| Matplotlib | Seaborn | |
|---|---|---|
| What it is | General-purpose plotting canvas | Statistical charts built for DataFrames |
| Analogy | A blank sketchpad | A sketchpad with the ruler and colors ready |
| In one line | plt.plot(x, y) | sns.scatterplot(data=df, ...) |
Use Matplotlib whenever you need full control over every visual detail. Use Seaborn whenever you want speed, especially while exploring a new dataset. In practice, most data scientists use both together — Seaborn for quick statistical plots, and Matplotlib underneath for fine-tuning.
Real-Life Examples You Already Know
You’ve encountered these exact concepts outside of coding, probably without realizing it. Consider a few familiar examples:
- Weather app maps – a colored map is a scatter plot wearing a costume
- News infographics – a bar chart comparing states or political parties works exactly like
plt.bar() - Fitness app weekly charts – your steps-per-day chart is
plt.bar(), rendered automatically for you - Stock market graphs – a rising or falling line is precisely what
plt.plot()draws
Matplotlib and Seaborn aren’t locked away inside a coding classroom. They’re already running quietly behind apps you open every single day.
Common Mistakes to Avoid When Visualizing Data
Even with the right tools, a few habits quietly ruin otherwise good charts. Watch out for these common pitfalls as you practice.
First, avoid skipping labels entirely. A chart without a title or axis labels forces your audience to guess at meaning. Always add them, even for quick exploratory charts you think nobody else will see.
Second, avoid cramming too many categories into one chart. A bar chart with thirty tiny bars becomes unreadable. Instead, group smaller categories together, or split the data across multiple charts.
Third, avoid choosing a chart type just because it looks fancy. A 3D pie chart might catch attention, but it usually distorts proportions and confuses viewers. Simple charts communicate far more clearly than complicated ones.
Fourth, avoid ignoring your color choices. Random colors add visual noise without adding meaning. Instead, use color intentionally, the same way Seaborn’s hue parameter groups categories with purpose.
Finally, avoid skipping the exploratory step. Jumping straight into modeling without visualizing your data first often hides problems that could have been caught early, such as missing values or extreme outliers.
Frequently Asked Questions
Is Seaborn a replacement for Matplotlib? No, not exactly. Seaborn actually runs on top of Matplotlib behind the scenes. Therefore, you’ll often use both together — Seaborn for fast statistical charts, and Matplotlib for fine control over smaller details.
Which library should beginners learn first? Start with Matplotlib, since it teaches the underlying concepts of figures and axes. Once those basics feel natural, Seaborn becomes much easier to understand, because you’ll recognize what’s happening underneath it.
Do I need to know statistics to use Seaborn? Not really. Seaborn handles the statistical calculations internally, whether you’re building a histogram, a box plot, or a regression line. You simply supply the data and the column names, and Seaborn takes care of the math.
Can I use these libraries with data outside of pandas? Yes, absolutely. Matplotlib works with plain Python lists and NumPy arrays as well. However, Seaborn works best with pandas DataFrames, since it relies on column names for its arguments.
What comes after data visualization in a machine learning workflow? After exploring and visualizing your data, the next step involves setting up a proper environment to build and train models. That’s precisely the topic of Episode 20, covering Jupyter, Scikit-learn, and Google Colab.
Quick Recap
Let’s summarize everything covered in this episode:
- You learned the three building blocks: Matplotlib, Seaborn, and choosing the right chart
- You understood how a figure, axes, and labels turn a plot into a clear message
- You saw one line of Seaborn code color and plot an entire DataFrame at once
- You practiced matching a question to its correct chart type, instead of picking the fanciest option
Each of these skills builds directly on the pandas foundation from Episode 18. Together, they form the visual layer that every machine learning workflow depends on.
What’s Next: Setting Up Your ML Environment
In Episode 20, we shift focus toward your actual workspace. You’ll set up Jupyter, Scikit-learn, and Google Colab, so you have a proper environment to run everything you’ve learned so far. Consequently, that episode bridges the gap between understanding concepts and actually executing code on your own machine or in the cloud.
Watch the Full Episode
This article summarizes the video, but the full walkthrough includes live coding, visual explanations, and a quick quiz to test your understanding. Watch Episode 19: Data Visualization (Matplotlib & Seaborn) on the Intelevo YouTube channel for the complete experience.
If this article helped clarify data visualization with matplotlib and seaborn, consider sharing it with someone learning data science for the first time. Charts become second nature with just a little consistent practice, and this episode gives you everything needed to start today.
