Data VisualizationNot Started
Line Plots
Visualize trends over time or ordered sequences
0%
Knowledge0%
Learn & DrillFluency0%
Drill & SpeedRetention0%
Mastery & ReviewConfidence0%
All modesKnowledge
Fluency
Retention
Knowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
Line plots connect data points in order — ideal for time series and continuous data.
python
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
x = [2019, 2020, 2021, 2022, 2023]
y = [100, 115, 108, 130, 145]
ax.plot(x, y, color='blue', linewidth=2,
marker='o', markersize=6, label='Revenue')
ax.set_title('Annual Revenue')
ax.set_xlabel('Year')
ax.set_ylabel('Revenue ($K)')
ax.legend()
plt.show()Key parameters:
color— line color ('red', '#FF5500', 'C0')linewidth/lw— line thicknesslinestyle/ls— '--' dashed, ':' dotted, '-.' dash-dotmarker— point markers: 'o' circle, 's' square, '^' trianglelabel— for the legend (callax.legend()to show it)
Multiple lines:
python ax.plot(x, y1, label='Product A') ax.plot(x, y2, label='Product B') ax.legend()
Examples
Comparing two trends
Each call to ax.plot() adds a line to the same axes
import matplotlib.pyplot as plt
years = [2019,2020,2021,2022,2023]
sales_a = [100,115,108,130,145]
sales_b = [80,95,120,115,135]
fig, ax = plt.subplots(figsize=(8,4))
ax.plot(years, sales_a, marker='o', label='Product A')
ax.plot(years, sales_b, marker='s', linestyle='--', label='Product B')
ax.set_title('Sales Comparison')
ax.legend()
plt.tight_layout()
plt.show()How well did you understand this?
Next in Data Visualization
Bar Charts