Matplotlib Foundations

ECON 3209 · Week 5, Lecture 1 · Kerala Agricultural University

Department of Development Economics, KAU

Autumn 2026

Learning Outcomes

By the end of this lecture, you will be able to:

  1. Explain the figure-and-axes model in Matplotlib
  2. Create line, bar, scatter, and histogram charts
  3. Label plots clearly for an economics audience
  4. Choose chart types that match the variable structure
  5. Build basic publication-quality figures with Python

Why Visualisation Matters

  • Tables are precise, but charts reveal patterns faster
  • Economists use plots to detect trends, outliers, and relationships
  • Good figures support decisions in agriculture and banking
  • Poor figures can hide the real message of the data
  • Visualisation is part of analysis, not only presentation

Figure and Axes

  • A figure is the whole canvas
  • An axes object is the actual plotting area
  • Most Matplotlib work happens on axes objects
  • This structure makes multi-panel charts easier later
  • Understanding it now will save confusion later

Bar Charts for Comparisons

  • Bar charts compare levels across categories
  • Keep the number of categories manageable
  • Labels should be readable without clutter
  • Use consistent colours unless colour itself encodes meaning

Scatter Plots for Relationships

  • Scatter plots show association between two numeric variables
  • They are useful before running regression models
  • Look for trends, clusters, and unusual points
  • A scatter plot suggests relationships; it does not prove causality

Histograms for Distributions

  • Histograms reveal the shape of a distribution
  • They show concentration, skewness, and possible outliers
  • The choice of bins affects the visual impression
  • Always label the unit clearly on the x-axis

Label Everything Clearly

  • A good plot answers: what, where, when, and in what units?
  • Titles should communicate the economic message, not just the variable name
  • Axis labels should include units such as kg/ha or ₹ crore
  • Legends are needed only when multiple series appear
  • Avoid decorative clutter that distracts from the data

If a classmate cannot interpret your plot in 10 seconds, the figure needs improvement.

Choosing the Right Chart Type

Use a Line Chart When

  • Data follows time order
  • You want to emphasise trend
  • Comparison of several series is needed

Use Bar / Scatter / Histogram When

  • Bar: compare categories
  • Scatter: examine relationships
  • Histogram: inspect distributions

A Simple Styling Upgrade

  • Small style changes can make a figure much easier to read
  • Removing extra borders often improves presentation quality
  • Use consistent colours across a lecture or report
  • Simplicity usually beats heavy decoration

Exercise

Create a bar chart of coconut yield for three districts using any sample values you choose.

  1. Add a title and y-axis label.
  2. Use KAU-style green shades if possible.
  3. Finish with plt.show().

Summary

  • ✅ Matplotlib uses a figure-and-axes model
  • ✅ Line, bar, scatter, and histogram charts answer different questions
  • ✅ Titles, labels, and units are essential for interpretation
  • ✅ Small style choices can greatly improve readability
  • ✅ Plots help economists see patterns before modelling
  • ✅ Every plotting cell in this course should end with plt.show()

Next Lecture

Seaborn Statistical Charts

  • We will build richer statistical graphics on top of Matplotlib
  • You will learn boxplots, heatmaps, pairplots, and distribution charts
  • These are especially useful for exploratory data analysis