Skip to main content
Course/Module 2/Topic 3 of 4Beginner

Matplotlib Visualization

Create beautiful and informative data visualizations

50 minBy Priygop TeamLast updated: Feb 2026

What is Matplotlib?

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. It provides a MATLAB-like plotting interface.

Basic Plotting

Example
import matplotlib.pyplot as plt
import numpy as np

# Create data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# Create plot
plt.figure(figsize=(10, 6))
plt.plot(x, y, 'b-', linewidth=2, label='sin(x)')
plt.plot(x, np.cos(x), 'r--', linewidth=2, label='cos(x)')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Trigonometric Functions')
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()

Different Plot Types

Example
# Scatter plot
plt.figure(figsize=(12, 4))

plt.subplot(1, 3, 1)
plt.scatter(x, y, alpha=0.6)
plt.title('Scatter Plot')

# Bar plot
plt.subplot(1, 3, 2)
categories = ['A', 'B', 'C', 'D']
values = [4, 3, 2, 1]
plt.bar(categories, values)
plt.title('Bar Plot')

# Histogram
plt.subplot(1, 3, 3)
data = np.random.normal(0, 1, 1000)
plt.hist(data, bins=30, alpha=0.7)
plt.title('Histogram')

plt.tight_layout()
plt.show()

Additional Resources

Recommended Reading

  • Python for Data Analysis by Wes McKinney
  • Python Data Science Handbook by Jake VanderPlas
  • NumPy and Pandas Official Documentation

Online Resources

  • NumPy Tutorial
  • Pandas Getting Started Guide
  • Matplotlib Tutorial
Chat on WhatsApp
Priygop - Leading Professional Development Platform | Expert Courses & Interview Prep