Data Science ยท Chapter 14 of 43
Data Visualization (matplotlib)
matplotlib is the base plotting library in Python. Every serious data plot in Python ultimately runs on it.
A good chart answers a specific question. Choose the chart type first, then style it.
Example 1 (python)
import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [10, 20, 15, 25])
plt.xlabel('day')
plt.ylabel('sales')
plt.title('Daily sales')
plt.show()Basic line chart.
Example 2 (python)
plt.bar(['A','B','C'], [4, 7, 3])
plt.show()Bar chart.
Key points
- matplotlib is the foundation.
- Always label axes and title.
- One chart, one message.
- Learn plot types (line/bar/scatter/hist).
๐ก Note: The number-one visualisation mistake is missing or unclear axis labels. Always label them.
