Line plots in Matplotlib (ax.plot()) track continuous numerical measurements across ordered intervals—most commonly time (days, months, quarters, or fiscal years)—making upward momentum, seasonality, and year-over-year gaps immediately visible.
Never use a line plot for unordered categories (like comparing cities or product names—use a bar chart for those). Reserve line plots for ordered sequences where slopes between consecutive points carry real meaning.
| Parameter | Common Values | Visual Purpose |
|---|---|---|
linestyle (ls) | '-' (solid), '--' (dashed), ':' (dotted), '-.' (dash-dot) | Distinguish baseline vs current year or actual vs forecast |
marker | 'o' (circle), 's' (square), '^' (triangle), 'D' (diamond) | Emphasize exact measurement timestamps |
linewidth (lw) | 1.5 to 3.5 | Give primary KPI series stronger visual weight |
alpha | 0.15 to 1.0 | Keep gridlines and shaded bands subtle and readable |
ax.fill_between()When comparing two series—such as FY 2025 vs FY 2026 revenue, or forecast confidence intervals—combine distinct linestyle/marker styles with ax.fill_between() to highlight the growth gap visually:
linestyle=':', alpha=0.5) so data lines remain the unmistakable hero.ax.plot() controls whether a line is solid, dashed, or dotted?ax.legend() do?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Matplotlib Anatomy: Figure, Axes, Subplots & Ticks | Bar Charts, Horizontal Bars & Stacked Bars |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.