28  Line Plots

Line plots (or line graphs) are a staple of data visualization, particularly useful for displaying trends and variation over time. They help analysts see how data points connect across a period or sequence — essential for spotting trends, cycles, and anomalies in something like a season’s rainfall or a commodity’s price.

28.1 Utility of Line Plots in Data Analysis

  1. Trend identification: line plots are excellent for observing trends over time — rainfall across a season, or mandi prices across months.

  2. Comparison: plotting multiple lines on one graph makes it easy to compare trends across categories — rainfall across several districts, side by side.

  3. Temporal changes: line plots suit continuously changing, sequentially ordered data, particularly time series.

  4. Smoothing and forecasting: a moving average can smooth out short-term noise to make the underlying trend clearer, and support simple forecasting.

28.2 Single-Series Line Plot

In R, the ggplot2 package provides a flexible way to build line plots. Make sure it’s installed first:

Code
install.packages("ggplot2")

The line makes the season’s monsoon peak in August, and the sharp drop by October, immediately visible — a shape that would take much longer to spot in a table of five numbers.


28.3 Multi-Line Comparison

Plotting several lines on the same axes — one per group — makes it possible to compare trends directly, such as how rainfall varied across three districts over the same months.

Coimbatore tracks consistently wetter than Warangal across every month shown — a comparison that a single-district line plot couldn’t make visible on its own.


28.4 Line Plot with a Moving Average

Real time series are noisy. A moving average — the mean of each point and its neighbors — smooths that noise so the underlying trend stands out, which is useful for something like a weekly mandi price series that jumps around from day to day.

The pale line is the raw weekly price; the green line is its 3-week moving average, smoothing the week-to-week noise so the broader trend across the 12 weeks is easier to read.


Summary

Concept Description
Line Plots
Utility of Line Plots Line plots identify trends, support comparison across groups, suit sequential/time-series data, and support smoothing and forecasting
Single-Series Line Plot Plots one variable against time, e.g., monthly rainfall across a season
Multi-Line Comparison Plots several groups' lines on one graph for direct comparison, e.g., rainfall by district
Line Plot with a Moving Average Overlays a moving average on a noisy series to reveal the underlying trend, e.g., a mandi price series