---
title: "Class 12 IP Data Visualization: Line, Bar, Histogram"
description: "Class 12 IP data visualization notes (065, 2026-27): line, bar and histogram in Matplotlib with real charts, the code behind each and solved questions."
canonical: https://learn.modernagecoders.com/cbse-class-12-informatics-practices-matplotlib-charts
source: src/pages/cbse-class-12-informatics-practices-matplotlib-charts.html
---
> Class 12 IP data visualization notes (065, 2026-27): line, bar and histogram in Matplotlib with real charts, the code behind each and solved questions.

Start here

## Courses where charts have something to say

A chart is only as good as the table under it. These courses keep the two together, beginning with the board subject.

[![Informatics Practices Class 11 and 12 course thumbnail](/images/ip-cs-class-11-12.webp)  065 / With pandas Informatics Practices 11 and 12 Line charts, bar graphs and histograms follow DataFrames, then CSV data is charted and both are revised with practical programs. Open the course →](/courses/cbse-informatics-practices-ip-class-11-12-python-pandas-sql-complete-course)[![Data Science for Teens course thumbnail](/images/data-science-teens.webp)  Beyond the syllabus Data Science for Teens A month of matplotlib on distributions, choosing the right chart and honest figures, ending with a four-chart story. Open the course →](/courses/data-science-course-for-teens-python-data)[![MySQL for Teens course thumbnail](/images/mysql-teens.webp)  Where data is kept MySQL for Teens Totals and groups that you would plot often come from a query first. Useful for the SQL unit and for projects. Open the course →](/courses/mysql-mastery-for-teens)

Ans. The short version

Class 12 IP data visualization (CBSE 065) is the part of Unit 1 where you show data as pictures using Matplotlib. The 2026-27 syllabus has three plots: line plot with plt.plot(), bar graph with plt.bar() and histogram with plt.hist(), customised by a title, axis labels and a legend, and saved with plt.savefig(). The sample paper asks a four-mark line graph program. Modern Age Coders teaches this live, personalised one to one, on your own timetable; a priority demo is a full class you can try before enrolling.

A. Before any code

## What is data visualization, and which plot should you use?

Data visualization means showing data as charts so that a change, a comparison or a pattern can be seen without reading every number. Its purpose is to help people draw conclusions.

| Your data | The question | Plot | Function |
| --- | --- | --- | --- |
| Values in an order: days, weeks, months | How did it change? | Line plot | `plt.plot(x, y)` |
| One value for each named thing | Which is more, which is less? | Bar graph | `plt.bar(names, values)` |
| One long list of numbers | How are they spread? | Histogram | `plt.hist(values, bins=...)` |

### Data visualization Class 12 notes: every function you need

| Function | What it does | A slip and its result |
| --- | --- | --- |
| `import matplotlib.pyplot as plt` | Brings in the plotting functions | `import matplotlib as plt`, then plt.plot: AttributeError |
| `plt.title("...")` | Heading above the chart | Called twice, the second replaces the first |
| `plt.xlabel("...")`, `plt.ylabel("...")` | Names the axes, with units | `plt.xlable`: AttributeError |
| `label="..."` inside the plot call | Names one line or one set of bars | Without legend() it is never shown |
| `plt.legend()` | Draws the box that lists the labels | With no label given: a warning and an empty box |
| `plt.savefig("a.png")` | Saves the figure; PNG and PDF both work | An unknown ending such as .xyz: ValueError |
| `plt.show()` | Displays the figure | Forgotten in the paper: half a mark |

**Save first, show after.** When a figure is closed, the next `savefig()` starts a new, empty one. We closed a figure and then saved: the file was a plain white image.

B. Change over an order

## How do you draw a line plot in Matplotlib for Class 12 IP?

Give plt.plot() two lists of equal length, x first and y second, then add the title, the axis labels and, if there is more than one line, a legend.

***One line**Matplotlib*

```
import matplotlib.pyplot as plt

day = [0, 3, 6, 9, 12, 15]
height = [0, 1.5, 4, 8.5, 13, 16]

plt.figure(figsize=(8, 5))             # size in inches
plt.plot(day, height)
plt.title("Height of one bean seedling")
plt.xlabel("Day")
plt.ylabel("Height (cm)")
plt.savefig("01-line-seedling.png", dpi=150)
plt.show()
```

***The chart**01-line-seedling.png*

![Line chart of the height of one bean seedling, rising from 0 to 16 cm in 15 days and steepest between day 6 and day 12](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/01-line-seedling.png)

Read it: growth is slow until day 3, quickest from day 6 to day 12, and a little slower at the end.

***Two lines, so a legend**Matplotlib*

```
import matplotlib.pyplot as plt

day = [0, 3, 6, 9, 12, 15]
compost = [0, 1.5, 4, 8.5, 13, 16]
plain = [0, 1.5, 3.5, 6, 8, 9.5]

plt.figure(figsize=(8, 5))
plt.plot(day, compost, color="seagreen", marker="o",
         label="With compost")
plt.plot(day, plain, color="sienna", marker="s",
         linestyle="--", label="Plain soil")
plt.title("Bean seedlings in two kinds of soil")
plt.xlabel("Day")
plt.ylabel("Height (cm)")
plt.legend()
plt.savefig("02-line-two-soils.png", dpi=150)
plt.show()
```

***The chart**02-line-two-soils.png*

![Two lines of seedling height, solid green with compost ending at 16 cm and dashed brown in plain soil ending at 9.5 cm, with a legend at top left](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/02-line-two-soils.png)

Read it: both are equal till day 3. By day 15 the compost seedling is 6.5 cm taller.

Two `plot()` calls before one `show()` share the same axes. The colour, marker and linestyle are extras: the syllabus asks for label, title and legend. If the lists differ in length, Matplotlib stops with ValueError. If you pass one list, it becomes y, and x is 0, 1, 2 and so on.

C. Comparing named things

## Bar graph program for Class 12 IP, from lists and from a CSV file

plt.bar() takes the names for the x-axis first and the heights second. The bars stand apart because the names are separate categories.

***From two lists**Matplotlib*

```
import matplotlib.pyplot as plt

classes = ["VI", "VII", "VIII", "IX", "X"]
paper_kg = [46, 38, 52, 27, 33]

plt.figure(figsize=(8, 5))
plt.bar(classes, paper_kg, width=0.6, color="seagreen",
        label="Waste paper")
plt.title("Waste paper collected for recycling")
plt.xlabel("Class")
plt.ylabel("Paper (kg)")
plt.legend()
plt.savefig("03-bar-paper.png", dpi=150)
plt.show()
```

***The chart**03-bar-paper.png*

![Bar graph of waste paper collected by classes VI to X: 46, 38, 52, 27 and 33 kg](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/03-bar-paper.png)

Read it: class VIII collected the most, 52 kg, and class IX the least, 27 kg.

***From a CSV file**Matplotlib*

```
import pandas as pd
import matplotlib.pyplot as plt

drive = pd.DataFrame([
    {"Class": "VI", "Kg": 46, "Students": 40},
    {"Class": "VII", "Kg": 38, "Students": 38},
    {"Class": "VIII", "Kg": 52, "Students": 52},
    {"Class": "IX", "Kg": 27, "Students": 18},
    {"Class": "X", "Kg": 33, "Students": 30}])
drive.to_csv("drive.csv", index=False)

drive = pd.read_csv("drive.csv")           # as in the lab
drive["Each"] = drive["Kg"] / drive["Students"]
print(drive)

plt.figure(figsize=(8, 5))
plt.bar(drive["Class"], drive["Each"], color="sienna")
plt.title("Waste paper per student")
plt.xlabel("Class")
plt.ylabel("Paper per student (kg)")
plt.savefig("04-bar-per-student.png", dpi=150)
plt.show()
```

***The chart**04-bar-per-student.png*

![Bar graph of waste paper per student: VI 1.15, VII 1.0, VIII 1.0, IX 1.5 and X 1.1 kg](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/04-bar-per-student.png)

Read it: class IX, last in the first chart, is first per student.

***Also printed**text*

```
  Class  Kg  Students  Each
0    VI  46        40  1.15
1   VII  38        38  1.00
2  VIII  52        52  1.00
3    IX  27        18  1.50
4     X  33        30  1.10
```

The two charts use one table and give opposite winners. Suggested practical 5.2 asks you to analyse a DataFrame and plot it with a title and legend, and a new column is often where the analysis is. `width` is 0.8 when you do not give it.

D. How values are spread

## What is a histogram in Class 12 IP, and how is it different from a bar graph?

A histogram groups one list of numbers into ranges called bins and draws a bar as tall as the number of values in each bin. A bar graph compares separate names; a histogram shows the spread of one quantity.

***Bins chosen by you**Matplotlib*

```
import matplotlib.pyplot as plt

grams = [182, 190, 205, 211, 214, 218, 222, 225, 226, 231,
         233, 235, 238, 240, 241, 244, 247, 252, 255, 258,
         263, 268, 274, 280, 291]
edges = [180, 200, 220, 240, 260, 280, 300]

plt.figure(figsize=(8, 5))
result = plt.hist(grams, bins=edges, color="seagreen",
                  edgecolor="black")
print(result[0])               # how many in each bin
plt.title("Weights of 25 mangoes from one tree")
plt.xlabel("Weight (g)")
plt.ylabel("Number of mangoes")
plt.savefig("05-hist-mangoes.png", dpi=150)
plt.show()
```

***The chart**05-hist-mangoes.png*

![Histogram of 25 mango weights in six 20-gram bins with bars of 2, 4, 7, 7, 3 and 2](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/05-hist-mangoes.png)

Read it: 14 of the 25 mangoes weigh from 220 g to just under 260 g.

***Also printed**text*

```
[2. 4. 7. 7. 3. 2.]
```

### Sort the same list by hand

| Bin | Values that fall in it | Count |
| --- | --- | --- |
| 180 to below 200 | 182, 190 | 2 |
| 200 to below 220 | 205, 211, 214, 218 | 4 |
| 220 to below 240 | 222, 225, 226, 231, 233, 235, 238 | 7 |
| 240 to below 260 | 240, 241, 244, 247, 252, 255, 258 | 7 |
| 260 to below 280 | 263, 268, 274 | 3 |
| 280 to 300 | 280, 291 | 2 |

240 and 280 sit on an edge and go to the bin on their right. Only the last bin includes both ends. A value outside all the edges is left out without any message, so check that the counts add up to the size of the list: here, 25.

***Bins given as a number**Matplotlib*

```
import matplotlib.pyplot as plt

grams = [182, 190, 205, 211, 214, 218, 222, 225, 226, 231,
         233, 235, 238, 240, 241, 244, 247, 252, 255, 258,
         263, 268, 274, 280, 291]

plt.figure(figsize=(8, 5))
result = plt.hist(grams, bins=3, color="sienna",
                  edgecolor="black")
print(result[0])
print(result[1])               # the edges it chose
plt.title("The same mangoes in three bins")
plt.xlabel("Weight (g)")
plt.ylabel("Number of mangoes")
plt.savefig("06-hist-three-bins.png", dpi=150)
plt.show()
```

***The chart**06-hist-three-bins.png*

![The same 25 mango weights in three wide bins with bars of 6, 12 and 7](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/06-hist-three-bins.png)

Read it: the middle is still tallest, but the detail has gone. With bins left out, Matplotlib uses 10.

***Also printed**text*

```
[ 6. 12.  7.]
[182.         218.33333333 254.66666667 291.        ]
```

### Bar graph and histogram compared

| Point | Bar graph | Histogram |
| --- | --- | --- |
| Data | Names and a value for each | One list of numbers |
| x-axis | Separate categories | A continuous scale cut into bins |
| Height of a bar | The value itself | How many values fall in the bin |
| Gaps | Bars stand apart | Bars touch |
| Order of bars | Can be changed | Fixed by the number scale |
| Example | Kilograms from each class | Weights of 25 mangoes |

E. In the answer book

## Matplotlib Class 12 IP questions: the four-mark program and the rest

The 2026-27 scheme gives 1 mark for the import, 1 for plot() with the label and half a mark each for title, axis labels, legend and show(). Data for an original one: skips in a minute over five weeks.

***Four marks, line by line**Matplotlib*

```
import matplotlib.pyplot as plt                     # 1 mark

week = ["W1", "W2", "W3", "W4", "W5"]
skips = [42, 55, 51, 68, 74]

plt.figure(figsize=(8, 5))
plt.plot(week, skips, marker="o", label="Skips")    # 1
plt.title("Rope skipping practice")                 # 1/2
plt.xlabel("Week")
plt.ylabel("Skips in a minute")                     # 1/2
plt.legend()                                        # 1/2
plt.savefig("07-line-skips.png", dpi=150)
plt.show()                                          # 1/2
```

***The chart**07-line-skips.png*

![Line chart of skips in a minute over five weeks: 42, 55, 51, 68 and 74](/images/board-prep/cbse-class-12-informatics-practices-matplotlib-charts/07-line-skips.png)

The figure() and savefig() lines are for the computer. In the paper, write them only if you are asked to set a size or save. The y-axis does not begin at 0, so read the numbers and not only the slope.

### One mark

1. Which function names the horizontal axis? Answer`plt.xlabel()`
2. Fill in: to show the labels of two lines in a box, call `plt.______()`. Answer legend
3. Which argument of hist() decides the number of ranges? Answer`bins`
4. Which plot suits the rainfall of twelve months in order, and which suits the heights of 60 students? Answer A line plot for the first, a histogram for the second.
5. What is the first argument of `plt.bar(a, b)` used for? Answer The categories along the x-axis. b gives the heights.
6. Name the statement that keeps a chart as the file trend.png. Answer`plt.savefig("trend.png")`
7. **Assertion:** In a histogram of 40 values, the heights of the bars add up to 40 if every value lies within the bins. **Reason:** Each bar shows the number of values in its bin. Answer Both are true and R explains A.
8. hist() is given the values 200, 220 and 240 with edges 180, 200, 220, 240. What are the three counts? Answer**0, 1, 2**. 200 goes to the second bin, 220 to the third, and 240 also to the third, because the last bin includes its end.

### Two marks

1. What is the purpose of a legend? When is it needed? Answer It tells which colour or style stands for which set of data. It is needed as soon as a chart has more than one line or set of bars.
2. Give two differences between a bar graph and a histogram. Answer Any two rows of the table above, such as: a bar graph has separate categories and the height is the value; a histogram has number ranges and the height is a count.
3. State the purpose of data visualization with one example. Answer To see patterns and comparisons quickly. Example: a line of monthly sales shows the month of the fall at once.

### Find five errors

***Wrong on purpose**a bar graph*

```
import matplotlib as plt
fruit = ["Guava", "Papaya", "Chikoo"]
sold = [25, 18]
plt.bar(fruit, sold, label="Sold")
plt.Title("Fruit sold on Monday")
plt.xlable("Fruit")
plt.legend
plt.show()
```

Corrections`import matplotlib.pyplot as plt`; a third value in `sold`; `plt.title` with a small t; `plt.xlabel`; and round brackets after `legend`. The last slip gives no error: the box is simply missing.

### Write it yourself

1. Plot a bar graph of the buses on five routes: R1 4, R2 7, R3 3, R4 6, R5 5. Give a title, both labels and save it as routes.png. (4 marks) Answer Import; `plt.bar(["R1", "R2", "R3", "R4", "R5"], [4, 7, 3, 6, 5])`; title; xlabel and ylabel; `plt.savefig("routes.png")`; show.
2. The column Minutes of a DataFrame d holds the time 50 people spent in a museum. Draw a histogram with bins of 15 minutes from 0 to 90. (3 marks) Answer`plt.hist(d["Minutes"], bins=[0, 15, 30, 45, 60, 75, 90])` with labels Minutes and Number of people.
3. Change the two-line program above so that a third seedling, kept in shade, is added. Answer One more list of six heights, one more `plt.plot()` with its own label before `plt.legend()`. Nothing else changes.

### For the practical

The file needs at least four Matplotlib programs, and a viva can start at a chart: why this plot, why these bins, what does the fall in week three mean? A complete set with output is in [the Class 12 IP practical file](/cbse-class-12-informatics-practices-practical-file), and spoken answers are in [IP viva questions](/cbse-class-12-informatics-practices-viva-questions).

### Sketch before code

The student draws the expected chart roughly on paper. A wrong choice of plot is noticed there, and not after ten lines of typing.

### One sentence each

No chart is finished until the student has said what it shows, with a number in the sentence.

### Six lines from memory

Import, plot, title, labels, legend, show: written by hand for a new set of data at the start of class until it is automatic.

Charts usually begin with a table, so revise [DataFrames](/cbse-class-12-informatics-practices-dataframe) and [Series](/cbse-class-12-informatics-practices-pandas-series) beside this page. For a full project built on charts see [the IP project with source code](/cbse-class-12-informatics-practices-project).

One to one, at your own timing

## Charts taught by someone who asks what they mean

Typing plt.bar is quick. Explaining why it should have been plt.hist takes a conversation, and that is what a personalised one to one class is. You decide the days and the time. To see one, take a priority demo: it is a paid full class, and if you enrol the amount is counted in the first month. Or take the free demo class. We bill month by month, there is no admission fee, and you are free to stop when a month ends.

Before you enrol · Try a class

### Priority demo, at a slot you pick

a full live class of about 45 to 60 minutes

- You pick the right plot for three small sets of data and defend it
- A four-mark program is written by hand and marked in halves
- The chart is drawn and saved from your own laptop
- A written report tells you which steps were missing

[Book a priority demo](/book-demo)

The classes · Choose your own timing

### Personalised one to one

₹4,999

per month, 4 private classes, fully flexible timing

- Line, bar and histogram until each is written from memory
- pandas repaired on the way, since most charts start in a table
- Your file and project charts discussed, drawn by you
- Chart reading in full sentences for the viva and the report

Ask for a personalised plan

Data visualization can be finished in a few classes, so the rest of the month can go to SQL or DataFrames. What a month costs is printed on this page in your own currency.

Studying outside India?

## Matplotlib lessons for 065 students overseas

CBSE schools in Riyadh, Doha and Singapore use the same three plots. Choose a time that falls after your school and before your dinner.

| Where you live | Time difference | Usual class window, local time | Format |
| --- | --- | --- | --- |
| India every Indian city | Indian time | Any time you choose | Personalised 1-on-1 |
| UAE and Oman Dubai, Abu Dhabi, Sharjah, Muscat | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Saudi Arabia, Qatar, Kuwait, Bahrain Riyadh, Jeddah, Dammam, Doha, Kuwait City, Manama | 2 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Nepal Kathmandu | 15 min ahead of India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Ethiopia and East Africa Addis Ababa and East Africa Time | 2 h 30 min behind India | 4:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore and Malaysia Singapore, Kuala Lumpur | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |

You need Python with pandas and Matplotlib. Installation trouble is common, so mention it when you book and the first class starts there.

What families say

## Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 12 series

## More pages for Class 12 students

Every page in the CBSE Class 12 Informatics Practices series, grouped by what you need.

### Practicals, project and viva

- [Class 12 IP practical file](/cbse-class-12-informatics-practices-practical-file)
- [Class 12 IP project with source code](/cbse-class-12-informatics-practices-project)
- [Class 12 IP project topics](/cbse-class-12-informatics-practices-project-topics)
- [Class 12 IP viva questions](/cbse-class-12-informatics-practices-viva-questions)

### Exam, papers and marks

- [Class 12 IP sample paper practice](/cbse-class-12-informatics-practices-sample-paper-2026-27)
- [Class 12 IP syllabus and pattern](/cbse-class-12-informatics-practices-syllabus-and-paper-pattern)
- [Class 12 IP important questions](/cbse-class-12-informatics-practices-important-questions)

### Questions and practice

- [Class 12 IP MCQ test](/cbse-class-12-informatics-practices-mcq-test)
- [Class 12 IP SQL questions](/cbse-class-12-informatics-practices-sql-questions)

### Chapter by chapter

- [Pandas Series Class 12 IP](/cbse-class-12-informatics-practices-pandas-series)
- [DataFrame Class 12 IP](/cbse-class-12-informatics-practices-dataframe)
- [Computer networks Class 12 IP](/cbse-class-12-informatics-practices-computer-networks)
- [Societal impacts Class 12 IP](/cbse-class-12-informatics-practices-societal-impacts)

### Revision and help

- [Class 12 IP crash course](/cbse-class-12-informatics-practices-crash-course)

**CBSE Class 12 Computer Science (083):** [Class 12 CS viva questions](/cbse-class-12-computer-science-viva-questions)  [Class 12 CS sample paper practice](/cbse-class-12-computer-science-sample-paper-2026-27)  [Class 12 CS project with source code](/cbse-class-12-computer-science-project-python-mysql)  [Class 12 CS important questions](/cbse-class-12-computer-science-important-questions)

**CBSE Class 12 Information Technology (802):** [IT 802 practical and project file](/cbse-class-12-it-802-practical-and-project-file)  [IT 802 Java notes and programs](/cbse-class-12-it-802-java-programs)  [IT 802 notes](/cbse-class-12-it-802-notes)

**CBSE Class 11 CS, IP and AI:** [Class 11 CS practical file](/cbse-class-11-computer-science-practical-file)  [Class 11 IP practical file](/cbse-class-11-informatics-practices-practical-file)  [CS or IP in Class 11](/computer-science-or-informatics-practices-class-11)

**ISC Computer Science (868):** [ISC Class 12 CS syllabus 2027](/isc-class-12-computer-science-syllabus-2027)  [ISC Class 12 CS practice paper](/isc-class-12-computer-science-specimen-paper-practice)  [ISC Class 12 practical questions solved](/isc-class-12-computer-science-practical-questions)  [ISC Boolean algebra and K-maps](/isc-class-12-computer-science-boolean-algebra)

**Program lists with output:** [Class 12 practical file programs](/blog/python-practical-file-class-12)  [Python programs for Class 11 CS and IP](/blog/python-programs-for-class-11)

Questions about charts

## Data visualization in Class 12 IP: what students ask

### What is data visualization in Class 12 IP?

Data visualization is the representation of data in the form of charts and graphs. In CBSE Informatics Practices 065 it is part of Unit 1 and is done with the Matplotlib library in Python. Its main purpose is to show trends, comparisons and the spread of values so that a reader can draw conclusions easily.

### Which plots are in the Class 12 IP syllabus 2026-27?

Three: line plot, bar graph and histogram. The syllabus also lists drawing and saving these plots, and customising them by adding a label, a title and a legend. Pie charts, scatter plots and box plots are not on the Class XII list for this session.

### What is Matplotlib and pyplot?

Matplotlib is a Python library for drawing charts. pyplot is the module inside it that has simple functions such as plot(), bar(), hist(), title() and show(). It is imported with import matplotlib.pyplot as plt, and plt is only the usual short name.

### What is the difference between a bar graph and a histogram?

A bar graph compares separate categories, and each bar shows the value of one category. A histogram shows how one set of numbers is distributed: the x-axis is divided into ranges called bins and each bar shows how many values fall inside. The bars of a histogram touch each other.

### What are bins in a histogram?

Bins are the ranges into which the values are grouped. bins=3 asks for three equal ranges between the smallest and largest value. A list such as [180, 200, 220] sets the edges yourself. Each bin includes its left edge and not its right one, except the last bin, which includes both.

### How do I add a legend in Matplotlib?

Give each plot a label, as in plt.plot(x, y, label="Sales"), and then call plt.legend() once before plt.show(). A label without legend() is not displayed, and legend() without any label shows an empty box and a warning.

### How do I save a chart in Python for my practical file?

Call plt.savefig("chart.png") before plt.show(). You may add dpi=150 for a sharper picture, and a name ending in .pdf also works. If you save after the figure has been closed, the file is blank.

### How many marks does data visualization have in Class 12 IP?

It shares 25 marks with pandas. In the 2026-27 sample paper, Question 4 (1 mark), Question 24 (2 marks) and Question 33 (4 marks) are on this topic, which makes 7. In the practical, pandas and Matplotlib programs together carry 8 of the 30 marks.

### How do I plot a DataFrame column?

Pass the columns to the plotting function: plt.bar(drive["Class"], drive["Kg"]) or plt.hist(d["Minutes"]). A column is a Series, and Matplotlib accepts it like a list. Import both pandas and matplotlib.pyplot at the top.

### Are colour, marker and linestyle needed in the board exam?

Write them only when the question asks. The official scheme for the line graph gives marks for import, plot with label, title, axis labels, legend and show. Extras are not in that scheme, so finish the listed lines first.

### Why does my Matplotlib program show no chart?

In a script, check that plt.show() is there with its brackets. Check the import line too, since import matplotlib alone does not give you plot(). If the window opens and is empty, the plot call probably came after show().

### Can I learn Matplotlib one to one for Class 12 IP?

Yes. The class is live, for one student, at the time you choose, and you draw every chart yourself. Try a priority demo of about 45 to 60 minutes first, with a written skill report after it and the fee adjusted in your first month if you enrol, or take a free demo class.

Start

## Turn one list of numbers into a chart

Come to the free demo class with any numbers you find interesting: cricket scores, bus timings, pocket money. Choosing the plot for them is the first exercise.

A **priority demo** covers more ground. You choose the slot, draw all three plots from new data, write the four-mark program by hand, and get a written skill report; the demo fee is adjusted against the first month if you go on.

More topics for a longer piece of work are on [Class 12 IP project topics](/cbse-class-12-informatics-practices-project-topics).

[WhatsApp us](https://wa.me/919123366161?text=Hello%20Modern%20Age%20Coders.%20I%20want%20one%20to%20one%20classes%20on%20Matplotlib%20and%20data%20visualization%20for%20CBSE%20Class%2012%20Informatics%20Practices%20065.) · [+91 91233 66161](tel:+919123366161) · [connect@modernagecoders.com](mailto:connect@modernagecoders.com)

Every class is live video. The form requests a callback and reserves nothing.

### Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

[Book a priority demo](/book-demo)

## Keep exploring Modern Age Coders

### By class and age

- [Class 12 Computer Science Syllabus 2026-27 (083) Explained](/cbse-class-12-computer-science-syllabus-2026-27)
- [Stack Class 12 Computer Science: Push, Pop and Questions](/cbse-class-12-computer-science-stack)
- [Class 12 Computer Science SQL Questions with Output (083)](/cbse-class-12-computer-science-sql-queries)
- [Class 12 Computer Science Revision Plan to 31 March 2027](/cbse-class-12-computer-science-revision-plan)
- [Python MySQL Connectivity Class 12: Programs and Errors](/cbse-class-12-computer-science-python-mysql-connectivity)
- [Class 12 Computer Science Project Topics: Python and SQL](/cbse-class-12-computer-science-project-topics)
- [Exception Handling Class 12 Computer Science: Notes, Q&A](/cbse-class-12-computer-science-exception-handling)
- [Class 12 Computer Science Crash Course 2027: Live 1-on-1](/cbse-class-12-computer-science-crash-course)
- [Computer Networks Class 12 Notes: CS 083 Unit 2 for 2027](/cbse-class-12-computer-science-computer-networks)

### Learn more

- [NumPy, Pandas & Matplotlib Masterclass: Python Data Analysis in Depth](/numpy-pandas-matplotlib-masterclass)
- [Orange Data Mining Course for Teens: Machine Learning Without Code](/courses/orange-data-mining-visual-machine-learning-course-for-teens)
- [High School Computer Science Access by State, 2025 Data](/high-school-computer-science-access-by-state)
- [Java Classes for Teens](/java-classes-for-teens)

### Free resources

- [Java Tutorial for Beginners to Advanced](/resources/java)
- [OOP Basics - Classes, Objects, and Constructors | Java Tutorial](/resources/java/object-oriented-programming-basics)
- [Triggers and Scheduled Events](/resources/sql/triggers-and-events)
- [Common Table Expressions (CTEs) and Recursive Queries](/resources/sql/common-table-expressions)

### From the blog

- [Java Constructors Explained: Types, Overloading, ICSE](/blog/java-constructors-explained)
- [The CBSE/ICSE Gap: What Schools Aren't Teaching About Tech](/blog/cbse-icse-gap-what-schools-not-teaching-about-tech)
- [Top 20 Java Programs for ICSE Class 10 (With Code)](/blog/top-20-java-programs-for-icse-class-10)

### Start here

- [About Modern Age Coders, teaching since 2020](/about)
- [Modern Age Coders pricing, one honest price per plan](/pricing)

---

*Canonical: https://learn.modernagecoders.com/cbse-class-12-informatics-practices-matplotlib-charts*
