School Revise · Class 12 Information Practices · Chapter 4
Code 065, Class 12. A chart shows data at a glance. Here we use Matplotlib to draw line, bar and scatter charts, and to label them clearly.
|
|
Matplotlib is a Python library for drawing charts. We import it as plt, draw a chart, add a title and labels, and show it.
plt.plot(x, y) draws a line chart, plt.bar(x, y) a bar chart, and plt.scatter(x, y) a scatter chart. plt.show() displays it.
|
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [2, 4, 6]) plt.show() (a line chart is displayed) |
plt.title(“…”) adds a title, plt.xlabel(“…”) and plt.ylabel(“…”) name the axes, and plt.legend() explains multiple lines.
A line chart shows change over time, a bar chart compares groups, and a scatter chart shows the link between two values.
Explore the idea by tapping. The interactive opens right here in the lesson.
Type each one into the code lab above, then open the card to see the worked solution and its output.
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
plt.plot().
plt.bar().
plt.title().
plt.show().
|
Matplotlib draws charts in Python. plt.plot() draws a line chart, plt.bar() a bar chart and plt.scatter() a scatter chart; plt.show() displays it. plt.title(), plt.xlabel(), plt.ylabel() and plt.legend() label a chart. Line charts show change, bar charts compare groups, and scatter charts show a link between two values. |
| Open the Virtual Lab |
These free Class 12 Informatics Practices notes explain plotting data with Matplotlib, line bar and scatter charts, adding titles and labels, and choosing the right chart with clear examples and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.
© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 12 Informatics Practices syllabus. Unauthorised copying is not permitted.