- Phase: 9. Databases & Web Apps
- Duration: 2.5 hours
- Create line plots, bar charts, scatter plots, histograms, and pie charts with matplotlib
- Customize figures with labels, titles, legends, colors, styles, and markers
- Use subplots to display multiple charts
- Save figures to files
- matplotlib.pyplot basics: figure and axes
- Line plots with plt.plot
- Bar charts with plt.bar and plt.barh
- Scatter plots with plt.scatter
- Histograms with plt.hist
- Pie charts with plt.pie
- Labels, titles, legends
- Saving figures with plt.savefig
- Subplots with plt.subplots
- Customization: colors, styles, markers
Modules 000-080.
import matplotlib.pyplot as plt
# Line plot
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.title('Line Plot')
plt.show()
# Subplots
fig, axes = plt.subplots(2, 2)
axes[0, 0].bar(['A', 'B', 'C'], [3, 7, 2])
axes[0, 1].scatter([1, 2, 3], [4, 5, 6])
plt.savefig('output.png')- matplotlib documentation: https://matplotlib.org
- pyplot tutorial
- matplotlib gallery for inspiration