NCERT Solutions Chapter 4 Plotting Data using Matplotlib – Easy and Concise

This article will provide NCERT Solutions Chapter 4 Plotting Data using Matplotlib. This can be also similar like
data visualization using pyplot class 12 solutions. Let’s start now.

NCERT Solutions Chapter 4 Plotting Data using Matplotlib

  1. What is the purpose of the Matplotlib library?
    • The purpose of Matplotlin Library is to present data on graphs.
    • You can create, animate interactive 2D plots or figures by using Matplolib library.
    • By plotting data you can visualize variation or show the relationships between various data elements.
  2. What are some of the major components of any graphs or plot?
    • Some of the major components of any graphs or plot are:
      • Plot Area or Figure or Chart Area
      • Legend
      • X Axis
      • Y Axis
      • Plot Title
      • ticks
      • Artists
      • If you want to read in detail about these components, click over here.
  3. Name the function which is used to save the plot.
    • savefig()
  4. Write short notes on different customization options available with any plot.
    • Chart customization refers to the process of changing the chart components’ styles, design and adds more attractive features to the graph.
    • The most common options used to customize the plot are as following:
      • title() – Applies titles for graphs with font size and color
      • grid() – Show/Hide the gridlines on plot
      • legend(): Represents the data displayed in the graph’s Y-axis
      • loc– Specify the location of the legend as “upper left” or “upper right”, “lower left”,”lower right”
      • plot(): Allows changing the linestyle, linewidth, color, marker ,marker size etc.
      • xlabel(), ylabel(): Specify the x and the y titles respectively you can change the fontsize and color
      • show(): displays the plot
      • savefig(): saves the plot at the specified location
  5. What is the purpose of a legend?
    • Legend represents the data displayed in the graph’s Y-axis.
    • It helps to understand what the colors and shapes in the graph mean in terms of data.
  6. Define Pandas visualization.
    • Pandas Visualization refers to the process of presenting data in pictorial or graphical form.
    • Visualization helps in a better and depth understanding of numerical data.
    • Pandas support visualization libraries and packages which is easy to use.
    • Pandas visualization also offers methods and properties to create graphs.
    • Pandas offer a single and convenient place to plot graphs i.e. matplotlib for visualization and data analysis through graphs.
  7. What is open data? Name any two websites from which we can download open data.
    • Open data refers to the data available on the internet to use them free without any license.
    • These open data can be used for data analysis primarily for educational purposes.
    • The two websites from where you can download data are:
  8. Give an example of data comparison where we can use the scatter plot.
    • The scatter plot is used to determine the association between two data variables.
    • It shows the correlation between two variables.
    • It can be also used for comparison between two values.
    • An example can be the run rate between two teams in specific overs
    • Comparison of marks of two different tests/exams
  9. Name the plot which displays the statistical summary.
    • To displays the statistical summary you can use bar plot and histogram.
  10. Plot the following data using a line plot:
Tickets Sold2000280030002500230025001000
  • Before displaying the plot display “Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday” in place of Day 1, 2, 3, 4, 5, 6, 7
  • Change the color of the line to ‘Magenta’.
import pandas as pd
import matplotlib.pyplot as plt
plt.plot(x,y,color="magenta",marker="*", label="No. of tickets")
plt.title("Day wise Tickets sold ")
plt.ylabel("No of tickets sold")
plt.savefig("d:\ Tickets.jpg")

11. Collect data about colleges in Delhi University or any other university of your choice and number of courses they run for Science, Commerce and Humanities, store it in a CSV file and present it using a bar plot.

import pandas as pd
 import matplotlib.pyplot as p
 df=pd.read_csv("D:\Python\IP NCERT XII Chapter 4\data.csv", index_col=0)
 p.title("Stream wise number of courses ")
 p.ylabel("No of Courses")

12. Collect and store data related to the screen time of students in your class separately for boys and girls and present it using a boxplot.

import matplotlib.pyplot as p
 boys = [8,5,6,10,11,9,7,16,2,4]

13. Explain the findings of the boxplot of Figure 4.18 by filling the following blanks:

(The figure in the textbook is 4.17)
a) The median for the five subjects is ______________, ___________________, ___________________, _______________, ______________


import pandas as pd
data= pd.read_csv('D:\Python\IP NCERT XII Chapter 4\Q13.csv')
df= pd.DataFrame(data)
print("Median English:",df.loc[:,'English'].median())
print("Median Maths:",df.loc[:,'Maths'].median())
print("Median Hindi:",df.loc[:,'Hindi'].median())
print("Median Science:",df.loc[:,'Science'].median())
print("Median Social_Science:",df.loc[:,'Social_Science'].median())

b) The highest value for the five subjects is : ____________, _______________________, ________________________, __________________, ___________

print("Max English:",df.loc[:,'English'].max())
print("Max Maths:",df.loc[:,'Maths'].max())
print("Max Hindi:",df.loc[:,'Hindi'].max())
print("Max Science:",df.loc[:,'Science'].max())
print("Max Social_Science:",df.loc[:,'Social_Science'].max())

c) The lowest value for the five subjects is : ________________, ________________, ___________________, _____________________, __________

print("Min English:",df.loc[:,'English'].min())
print("Min Maths:",df.loc[:,'Maths'].min())
print("Min Hindi:",df.loc[:,'Hindi'].min())
print("Min Science:",df.loc[:,'Science'].min())
print("Min Social_Science:",df.loc[:,'Social_Science'].min())

d)___________ subject has two outliers with the value ___________________ and __________________

The Social Science subject has two outliers with the values 54 and 95.
e) _________ subject shows the minimum variation

The Social Science shows the minimum variations the value is 113.064103

14. Collect the minimum and maximum temperature of your city for a month and present it using a histogram plot.

import pandas as pd
import matplotlib.pyplot as plt
plt.title("Minimum Temperatures in city During Fenruary 2021")

The similar way you can do for maximum temperature also.

  1. Conduct a class census by preparing a questionnaire. The questionnaire should contain a minimum of five questions. Questions should relate to students, their family members, their class performance, their health etc. Each student is required to fill up the questionnaire. Compile the information in numerical terms (in terms of percentage). Present the information through a bar, scatter–diagram. (NCERT Geography class IX, Page 60).

Do this questions by yourself.

16. Visit , search for the following in “catalogs” option of the website:
• Final population Totals, India and states
• State Wise literacy rate
Download them and create a CSV file containing population data and the literacy rate of the respective state. Also add a column Region to the CSV file that should contain the values East, West, North and South. Plot a scatter plot for each region where X axis should be population and Y axis should be Literacy rate. Change the marker to a diamond and size as the square root of the literacy rate. Group the data on the column region and display a bar chart depicting the average literacy rate for each region.

Do yourself.

Watch the video for more understanding:

Follow the below-given links to access notes on Plotting Data using Matplotlib:

Plotting Data using Matplotlib Notes for Class 12

Creating Histogram in Python IP Class 12

Import Questions for Plotting Data using Matplotlib Class 12

Questions for creating a histogram in Python Class 12 IP

Practical programs on data visualization for class 12

So I hope you enjoyed this article Plotting Data using Matplotlib NCERT solutions for class 12 IP.

If you have any queries regarding this solutions Plotting Data using Matplotlib, feel free to ask in the comment section.

Feel free to share your opinion, views, suggestions and feedback in the comment section.

Thank you for reading this article Plotting Data using Matplotlib.

Leave a Reply