- Регистрация
- 9 Май 2015
- Сообщения
- 1,605
- Баллы
- 155
— 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.
Below are the essential chart types every Data Analyst should know:
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()
Used to compare categories.
categories = ["A", "B", "C"]
values = [20, 35, 30]
plt.bar(categories, values)
plt.title("Bar Chart")
plt.show()
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()
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()
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()
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()
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()
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()
- 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.
Источник: