Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Practical 9: Line Chart for 10 Unit Test Marks

Lesson 9 of 15 in the free Data Visualisation and Analytics Lab notes on Siksha Sarovar, written by Rohit Jangra.

Aim

To store a student's marks in 10 unit tests in a list marks and plot them as a line chart with plt.plot(), using markers, axis labels and a grid so the trend across tests is readable.

CO Mapping: CO1, CO2

Theory

A line chart encodes an ordered sequence: the x-axis carries an inherently ordered variable (here, test number 1–10) and connecting the points with line segments encodes continuity — the claim that it is meaningful to travel from one observation to the next. That is why lines suit time series and sequences but are wrong for unordered categories (connecting "Delhi" to "Pune" with a line asserts an order that does not exist; that is bar-chart territory, as in Practical 5).

The eye reads three things from a line chart, in order of salience:

  • Slope — the local direction of change between consecutive tests; the steeper the segment, the bigger the jump.
  • Trend — the overall drift once local wiggles are smoothed away.
  • Outliers/dips — points that break the prevailing pattern and deserve a causal question.

Craft choices in the snippet serve those readings: marker="o" shows where the actual data lives (the line between markers is interpolation, not measurement); plt.xticks(tests) forces one tick per test so matplotlib cannot invent fractional test numbers like 2.5; and plt.grid(True, alpha=0.3) adds faint rulings for value look-up without shouting over the data. As in Practical 5, matplotlib.use("Agg") is selected before importing pyplot so the script renders to a PNG file even on headless machines.

Dataset

Test12345678910
Marks62687175707882808489

Procedure

  1. Create the list marks with the 10 scores and tests = list(range(1, 11)) for the x-axis — the two lists must be equal in length.
  2. Print marks as the data record.
  3. Inside the try block, set the Agg backend, then import pyplot.
  4. Call plt.plot(tests, marks, marker="o", linestyle="-") — x first, y second.
  5. Add title, xlabel ("Test Number"), ylabel ("Marks"), integer ticks via plt.xticks(tests) and a light grid.
  6. Save the figure with plt.savefig("unit_test_line_chart.png"); the except branch reports gracefully if no plotting backend exists.

Interpretation of Results

The line climbs from 62 in test 1 to 89 in test 10 — a net gain of 27 marks, an unmistakable upward trend. The rise is not monotonic: there are two dips, test 5 (75 → 70) and test 8 (82 → 80), visible as short downward segments against the prevailing upward slope. The steepest single climb is test 5 to 6 (70 → 78, +8), a recovery immediately after the worse dip. An analyst reads this as sustained improvement with local setbacks: the trend answers "is the student improving?" (yes), while the dips prompt the follow-up questions a table of ten numbers would never surface as quickly — what happened around tests 5 and 8?

Common Mistakes

  1. Plotting plt.plot(marks) alone — matplotlib then numbers the x-axis 0–9, so every "test number" in the chart is off by one.
  2. Omitting plt.xticks(tests) and getting fractional ticks (2.5, 7.5) for a variable that only takes integer values.
  3. Using a line chart for categorical data — the connecting line falsely implies an ordered progression between categories.

🎯 Viva Questions

  1. When is a line chart appropriate? When the x-variable is ordered (time, sequence) so connecting consecutive points is meaningful.
  2. What do the markers add? They show the actual observations; the segments between them are visual interpolation, not data.
  3. What is the overall trend and net change here? Upward — from 62 to 89, a net gain of 27 marks across 10 tests.
  4. Which tests show a drop in performance? Test 5 (75 → 70) and test 8 (82 → 80).
  5. Why must tests and marks have equal length? plt.plot(x, y) pairs elements positionally; unequal lengths raise a ValueError.
  6. How would you plot two students on one chart? Call plt.plot() twice with a label= each, then plt.legend().