HuntExams Academy logo
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.

๐Ÿ“ Quick Quiz

1. plt.plot draws by default:

2. Which method sets the title?

3. A good chart: