Skip to content
Programs · Program 4-1

Q.(Program 4-1: Plotting Temperature against Height) In a city, the maximum temperature of a day is recorded for three consecutive days. Plot the temperature values against the given dates as a line chart, given: date = ["25/12", "26/12", "27/12"] and temp = [8.5, 10.5, 6.8].

Sikkim CbseNCERTSubjective· 3mImportance★★★★★est
2% · 1/44 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Concept understanding — Matplotlib Plotting Basics

Matplotlib Plotting Basics

You already understand a graph. When you see a line going up on a news chart, you know sales are rising. When you see a bar taller than another, you know one category is bigger. That instinct is all you need. Matplotlib is simply the tool that lets you draw those same graphs on a computer — using Python instead of a pen.

The core idea is this: you give Matplotlib a list of numbers for the horizontal axis and a list for the vertical axis, and it draws the points, connects them, or makes bars, exactly as you would on graph paper. The computer does the tedious work of spacing, scaling, and labelling, so you can focus on what the data says.

What you are actually doing

Every plot you make has the same skeleton. You create a figure — that is the blank canvas or the whole window. Inside the figure, you create one or more axes — these are the actual plotting areas with the x and y lines. Then you tell those axes what kind of picture to draw: a line, a bar, a scatter of dots, or a pie.

Note

In everyday language, people say "axes" to mean the two perpendicular lines (x-axis and y-axis). In Matplotlib, an "Axes" object is the entire plotting area including those lines, the ticks, the labels — everything inside the frame. A "Figure" can hold several such Axes side by side.

The three most common plot types

Line plot — connects points in order. Use this when you want to show a trend over time or across a sequence. For example, monthly expenses from January to June: the line rises and falls, and you instantly see which month was the highest.

Bar plot — uses vertical or horizontal bars. Use this when you want to compare separate categories. For example, sales in different cities: each city gets its own bar, and the height shows the value. No line connects them because the categories are not a continuous sequence.

Pie chart — a circle cut into slices. Use this when you want to show parts of a whole. For example, how your monthly budget is divided among rent, food, travel, and savings. Each slice is proportional to its share.

Why it matters for a commerce or humanities student …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.