Line Plots
A line plot connects a series of data points with straight line segments, in the order they occur along the x-axis. It is the go-to chart for showing how a value changes continuously - most commonly over time.
When to Use a Line Plot
- Trends over time - stock prices, sales figures, temperature readings
- Continuous progression - any variable measured at regular, ordered intervals
- Comparing multiple series - plotting several lines together to compare trends
Plotting in Python
import matplotlib.pyplot as plt
plt.plot(months, revenue, color="#ff5421", marker="o")
plt.xlabel("Month")
plt.ylabel("Revenue")
plt.title("Monthly Revenue Trend")
plt.show()
Multiple Lines
You can plot more than one line on the same axes to compare series directly - for example, revenue vs. expenses across the same months. Each call to plt.plot() before plt.show() adds another line, and a legend() helps distinguish them.
Line Plot vs Scatter Plot
A line plot assumes the x-axis has a meaningful order (like time), and connects points to emphasize trend and direction. A scatter plot makes no such assumption and is better suited to spotting correlation between two independent variables.