Module 5: Charts with matplotlib · 8 min
Choosing the right chart
| Question | Chart | matplotlib call |
|---|---|---|
| Compare categories | Bar chart | plt.bar(x, y) |
| Change over time | Line chart | plt.plot(x, y) |
| Relationship between two numbers | Scatter plot | plt.scatter(x, y) |
| Spread of one number | Histogram | plt.hist(values) |
Pie charts are hard to read when there are more than 3 or 4 slices. A sorted bar chart is usually clearer.