Lesson 39 of 55
PythonData Visualization with Matplotlib
20 minutes
Course progress71%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 39 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Matplotlib is the go‑to library for creating static, animated, and interactive plots in Python.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 200)
plt.plot(x, np.sin(x), label='sin(x)')
plt.plot(x, np.cos(x), label='cos(x)')
plt.title('Sine and Cosine Waves')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.grid(True)
plt.show()
You can customize colors, markers, subplots, and export figures with plt.savefig('plot.png').