Plotting Data using Matplotlib
Class 12 · Informatics Practices
4 ideas in Class 12 Informatics Practices, explained in plain words, with games and quizzes to practise.
First Steps with Plots
Part of: Drawing and Styling Charts
A figure is the window holding a chart. Plotting temperatures 8.5, 10.5, 6.8 against three dates draws a line chart by default, and show displays it while savefig stores it as an image.
Why it matters. Charts make trends visible at a glance. A labelled, saved chart communicates results that raw numbers hide.
Key words
- Figure
- : The window that holds a chart and its labels.
- Line chart
- : Joins ordered points with lines to show a trend.
- Axis label
- : Names the quantity and unit along a side.
- Legend
- : Matches each plotted line to its name when several share a chart.
Try it in two minutes
- Plot three temperatures on paper with dates across and degrees upward.
- Join the dots and spot the highest day together.
- Add a title and axis labels and ask what each tells.
- Discuss when to display a chart and when to save it.
Try at home. Record three evening temperatures, draw them as a line chart, and title and label it.
Dressing Up a Chart
Part of: Drawing and Styling Charts
A marker stamps a symbol like a star on each point, colour codes like green pick the ink, linewidth sets thickness in pixels, and linestyle picks solid, dashed, dotted or dashdot patterns.
Why it matters. Styling separates overlapping lines and spotlights key points. Plain default charts blur together when several series share space.
Key words
- Marker
- : A symbol stamped on each plotted point.
- Colour code
- : A short letter or name fixing the ink, like green.
- Linewidth
- : Thickness of the line measured in pixels.
- Linestyle
- : The pattern of the line, such as solid or dashed.
Try it in two minutes
- Draw two overlapping lines in one colour and try telling them apart.
- Redraw one dashed and ask which is easier to follow.
- Stamp stars on the data points of one line.
- Thicken one line and compare readability.
Try at home. Draw the same three-point line twice, once plain and once with stars and dashes, and pick the clearer one.
Line, Bar and Histogram
Part of: Choosing the Right Chart
A line chart follows change across days, a bar chart compares weekday sales side by side with day names on the horizontal axis, and a histogram counts how often values fall into each range, like 3 values in the first of two bins.
Why it matters. Each shape answers a different question: trend, comparison or distribution. Picking wrongly hides the very pattern you seek.
Key words
- Bar chart
- : Compares categories with bars, tallest wins.
- Histogram
- : Counts how many values fall into each range.
- Bin
- : One range bucket of a histogram.
- Trend
- : The overall direction of change across time.
Try it in two minutes
- Plot weekday sales as bars and crown the tallest day.
- Join the same sales with a line and trace the weekly trend.
- Drop heights into two ranges and count each range.
- Ask which chart answered each question best.
Try at home. Chart your last week of study hours as bars and as a line, then note what each reveals.
Scatter, Box and Pie
Part of: Choosing the Right Chart
Scatter dots pair two measures like discount and sales to reveal their link. A box plot squeezes data into quartiles with the median as the middle line, and a pie chart cuts shares like 16.7, 33.3 and 50.0 percent that always total 100.
Why it matters. Links guide pricing, boxes expose skew at a glance, and pies show shares of a whole. Each answers a question bars cannot.
Key words
- Scatter chart
- : Plots paired values as dots to reveal their link.
- Median line
- : The middle line of a box, splitting data in half.
- Interquartile range
- : The span of the middle half, third quartile minus first.
- Pie share
- : One slice sized by its percent of the total.
Try it in two minutes
- Plot five discounts against sales and trace the rising dots.
- Order four numbers and box the middle half to show quartiles.
- Cut a paper circle into 10, 20, 30 shares and weigh the pieces.
- Check that the pie percentages total 100.
Try at home. Scatter your last five test scores against study hours, then pie your week into study, play and rest shares.
What your child will practise
- Dressing Up a Chart: Jungle Quick Fire (Quick Fire)
- First Steps with Plots: Candy Quick Fire (Quick Fire)
- First Steps with Plots: Space Puzzle (Clue Puzzle)
- Line, Bar and Histogram: Desert Quick Fire (Quick Fire)
- Scatter, Box and Pie: Jungle Puzzle (Clue Puzzle)
- Quiz: Dressing Up a Chart (8 questions)
- Quiz: First Steps with Plots (8 questions)
- Quiz: Line, Bar and Histogram (8 questions)
- Quiz: Scatter, Box and Pie (8 questions)