DEV Community

Ramya .C
Ramya .C

Posted on

πŸ“Š Day 64 of My Data Analytics Journey!

β€” Learning Matplotlib (All Charts Explained!)

Today, I worked with Matplotlib, the most fundamental Python library for data visualization.
It allows you to turn raw data into meaningful graphs that help in understanding patterns, trends, and insights.


πŸ”₯ What I Learned β€” Matplotlib Chart Types

Below are the essential chart types every Data Analyst should know:


1️⃣ Line Chart

Used to show trends over time.
Use case: Monthly sales trend.

import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = [10, 20, 15, 25, 30]

plt.plot(x, y)
plt.title("Line Chart")
plt.xlabel("Months")
plt.ylabel("Sales")
plt.show()
Enter fullscreen mode Exit fullscreen mode

2️⃣ Bar Chart

Used to compare categories.

categories = ["A", "B", "C"]
values = [20, 35, 30]

plt.bar(categories, values)
plt.title("Bar Chart")
plt.show()
Enter fullscreen mode Exit fullscreen mode

3️⃣ Histogram

Shows the distribution of data.

data = [22,25,29,21,28,30,27,26,32,24]

plt.hist(data, bins=5)
plt.title("Histogram")
plt.show()
Enter fullscreen mode Exit fullscreen mode

4️⃣ Scatter Plot

Used to find the relationship between two variables.

x = [1,2,3,4,5]
y = [5,20,15,25,30]

plt.scatter(x, y)
plt.title("Scatter Plot")
plt.show()
Enter fullscreen mode Exit fullscreen mode

5️⃣ Pie Chart

Used to show parts of a whole.

sizes = [30,25,20,25]
labels = ["A","B","C","D"]

plt.pie(sizes, labels=labels, autopct="%1.1f%%")
plt.title("Pie Chart")
plt.show()
Enter fullscreen mode Exit fullscreen mode

6️⃣ Box Plot

Helps identify data spread and outliers.

data = [22,25,29,21,28,30,27,26,32,24]

plt.boxplot(data)
plt.title("Box Plot")
plt.show()
Enter fullscreen mode Exit fullscreen mode

7️⃣ Area Chart

Shows cumulative progress.

x = [1,2,3,4,5]
y = [3,8,2,10,5]

plt.fill_between(x, y)
plt.title("Area Chart")
plt.show()
Enter fullscreen mode Exit fullscreen mode

8️⃣ Heatmap (Using seaborn for better visuals)

Helps show patterns between variables.

import seaborn as sns
import numpy as np

data = np.random.rand(5,5)
sns.heatmap(data, annot=True)
plt.title("Heatmap")
plt.show()
Enter fullscreen mode Exit fullscreen mode

✨ Additional Things I Practiced

  • Customized chart colors and styles
  • Adjusted figure sizes
  • Added labels, legends, and titles
  • Created multiple plots using subplot()
  • Saved charts as images

These visualizations help communicate insights clearly β€” a must-have skill for Data Analysts.


πŸš€ Consistency is my strength. Day 64 completed.

RamyaAnalyticsJourney

πŸ”— GitHub Link:

https://github.com/ramyacse21/matplotlib_python/blob/main/practice%20matplotlib%20pie%20chart.py
https://github.com/ramyacse21/matplotlib_python/blob/main/practice%20matplotlib.py

Top comments (0)