Theory
Three tests, one worrying whisper
The DBMS faculty whispers: "I think the class is slipping."
ResultDesk has the receipts: class averages across three internal tests: 62, 58, 51.
Three numbers in a row already hint at the story, but scale it to five subjects and three tests each, and the table fogs over. What the eye wants is the direction of travel: rising, falling, flat. That is precisely one chart's whole job: the line chart.
Theory
Connect the dots, read the slope
Mark the three test averages on graph paper and connect them left to right. The line you drew IS the analysis:
- Sloping down: the whisper was right, the class is slipping.
- The steepness says how fast.
- A sudden kink says something happened between those two tests.
A line chart is a connect-the-dots where the dots have a natural order, and the slope does the talking.
Theory
Line chart, formally
plt.plot(x, y) connects consecutive (x, y) points with line segments.
Use it when x has a natural order: test numbers, months, years. The connecting line claims "the journey between these points is meaningful": true for test 1 → test 2, false for student 101 → student 102 (last lesson's zigzag).
Useful dress-up: marker='o' shows the actual data points on the line, linestyle='--' for a dashed reference, color= to control colours.
Practical
Two subjects, three tests, one verdict
import matplotlib.pyplot as plt
tests = [1, 2, 3]
dbms_avg = [62, 58, 51]
maths_avg = [65, 66, 68]
plt.plot(tests, dbms_avg, marker='o', label='DBMS')
plt.plot(tests, maths_avg, marker='o', label='Maths')
plt.title('Class average across internal tests')
plt.xlabel('Internal test')
plt.ylabel('Average score')
plt.legend() # keys the two lines by their label=
plt.show()
# The picture: Maths gently rising, DBMS falling test by test.
# One chart replaced the whisper with evidence.
This example runs in Gri-Learn on the web, where you can edit it and see the output.
Quiz
You must show how ONE student's total marks changed across semesters 1 to 4. Which chart, and why?
- Line chart: semesters are ordered, and the slope shows the trend across them
- Scatter plot: any two numeric columns means scatter
- Bar chart: totals are always bars
- Histogram: marks always go in a histogram
Show the answer
Line chart: semesters are ordered, and the slope shows the trend across them
Semesters 1 to 4 form a natural sequence, and the question is about change along that sequence: the line chart's exact territory: the slope literally answers "improving or declining?". Scatter drops the order (and with 4 points, shows almost nothing), bars would work but bury the trend the question asks for, and a histogram answers a different question entirely (distribution, next lesson).
Think first
The slope that lied
A chart shows DBMS falling 62 → 58 → 51... but the y axis runs from 50 to 63, making the line plunge like a cliff. Before tapping: is the DATA wrong, and what should a careful reader check before panicking?
Show the answer
The data is honest; the axis is dramatic. A y axis clipped to 50..63 stretches an 11-point dip across the whole chart height, tripling the visual panic.
Careful readers check the y-axis range first, always. As the chart-maker, either start near zero or clearly label the range: exams (and newspapers) are full of truncated-axis exaggerations, and "check the axis scale" is the professional reflex this lesson wants installed.
Watch out
The three line-chart slips
Lines through unordered categories: cities or student names on x with a connecting line implies a journey that does not exist: that is bar-chart territory (two lessons ahead).
label= forgotten: legend() shows an empty box; every series needs its name at plot() time.
Axis drama: truncated y axes exaggerate slopes: read and design with the scale in mind.
Theory
The dashboard chart
Line charts run the world's dashboards: sensex across months, daily active users, temperature by hour, your own weight by week. Any metric-over-time question defaults to a line. ResultDesk's falling DBMS line, shown in the staff meeting, is the moment this subject's tooling becomes institutional evidence: next, distributions (histogram) and category comparisons (bar) complete the kit.
Summary
Key takeaways
- plt.plot(x, y) connects ordered points: the slope is the story (rising, falling, kinks).
- Only plot lines along a naturally ORDERED x: tests, months, years.
- Multiple series: one plot(label=...) per line, then legend().
- marker='o' shows the real data points; linestyle/color for styling.
- Check the y-axis range before trusting a dramatic slope: truncation exaggerates.
- Line = trend over order; scatter = relation across records; bar = categories.
- Memory hook: connect the dots, read the slope.