Module 5: Charts with matplotlib · 8 min
Making charts clear and honest
- Start bar charts at zero. A cut-off axis makes small differences look huge.
- Use few colours and make them meaningful.
- Sort bars from largest to smallest unless the order has meaning (for example months).
- Put units on the axis and a source under the chart.
- Write the message in the title: 'Lahore sells most' says more than 'Sales'.
plt.figure(figsize=(8, 4))
plt.plot([2021, 2022, 2023, 2024], [10, 14, 19, 27], marker="o")
plt.title("Yearly users grew every year")
plt.xlabel("Year")
plt.ylabel("Users (thousands)")
plt.grid(True)
plt.tight_layout()
plt.show()