Data Science

Your First Line Chart with Matplotlib

SQL Mastery Team
May 28, 2026
5 min read

It's **Day 127**, and we're drawing. A Line Chart is the best way to show a "Story" over time (revenue growth, user signups).

The Syntax

import matplotlib.pyplot as plt

days = [1, 2, 3, 4, 5]

sales = [100, 150, 120, 200, 180]

plt.plot(days, sales)

plt.show()

Adding Professional Polish

A chart without labels is just a line. Always add these:

plt.plot(days, sales, color='blue', marker='o') # Blue line with dots

plt.title("Weekly Sales Trend")

plt.xlabel("Day of Week")

plt.ylabel("Sales ($)")

plt.grid(True)

plt.show()

Plotting from a DataFrame

The real magic is plotting directly from Pandas:

df.groupby('month')['revenue'].sum().plot(kind='line')

plt.show()

Your Task for Today

Plot a trend line for a list of 10 numbers and customize the color and markers.

*Day 128: Bar Charts: Comparing Categories.*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.