Data Visualization Using Pyplot: book back answers
14 solved questions from the end of this chapter, Class 12 Computer Science, Tamil Nadu State Board. Each answer is checked against the textbook, and you can open the page that proves it.
← Notes and quiz for Data Visualization Using PyplotChoose the best answer (1 Mark)
Identify the package manager for installing Python packages, or modules.
- a. Matplotlib
- b. PIP
- c. plt.show()
- d. python package
Try it, then show the answerAnswer
b. PIP
The chapter identifies Pip as the package manager for installing Python packages.
From the book: “Pip is a Package manager software for installing python packages.”
Which of the following feature is used to represent data and information graphically?
- a. Data List
- b. Data Tuple
- c. Classes and Objects
- d. Data Visualization
Try it, then show the answerAnswer
d. Data Visualization
Data Visualization is the graphical representation of information and data.
From the book: “Data Visualization is the graphical representation of information and data.”
.......... is a collection of resources assembled to create a single unified visual display.
- a. Interface
- b. Dashboard
- c. Objects
- d. Graphics
Try it, then show the answerAnswer
b. Dashboard
The chapter defines a dashboard as a collection of resources creating a unified visual display.
From the book: “A dashboard is a collection of resources assembled to create a single unified visual display.”
Which of the following module should be imported to visualize data and information in Python?
- a. csv
- b. getopt
- c. mysql
- d. matplotlib
Try it, then show the answerAnswer
d. matplotlib
Matplotlib is the data visualization library in Python described in the chapter.
From the book: “Matplotlib is the most popular data visualization library in Python.”
Identify the right type of chart using the following hints. Hint 1: This chart is often used to visualize a trend in data over intervals of time. Hint 2: The line in this type of chart is often drawn chronologically.
- a. Line chart
- b. Bar chart
- c. Pie chart
- d. Scatter plot
Try it, then show the answerAnswer
a. Line chart
The chapter says line charts are often used to visualize trends over time and are drawn chronologically.
From the book: “A Line Chart is often used to visualize a trend in data over intervals of time”
Read the statements given below. Identify the right option from the following for pie chart. Statement A: To make a pie chart with Matplotlib, we can use the plt.pie() function. Statement B: The autopct parameter allows us to display the percentage value using the Python string formatting.
- a. Statement A is correct
- b. Statement B is correct
- c. Both the statements are correct
- d. Both the statements are wrong
Try it, then show the answerAnswer
c. Both the statements are correct
The chapter states both that plt.pie() creates a pie chart and that autopct displays percentage values.
From the book: “The autopct parameter allows us to display the percentage value using the Python string formatting.”
Part - II — Answer the following questions (2 Marks)
What is Data Visualization?
Try it, then show the answerAnswer
Data Visualization is the graphical representation of information and data. Its objective is to communicate information visually to users.
The chapter defines data visualization as a graphical representation intended to communicate information visually.
From the book: “The objective of Data Visualization is to communicate information visually to users.”
List the general types of data visualization.
Try it, then show the answerAnswer
Charts, Tables, Graphs, Maps, Infographics, and Dashboards.
These are the general types listed in the chapter.
From the book: “Charts • Tables • Graphs • Maps • Infographics • Dashboards”
List the types of Visualizations in Matplotlib.
Try it, then show the answerAnswer
Line plot, Scatter plot, Histogram, Box plot, Bar chart, and Pie chart.
The chapter lists these as types of visualizations under Matplotlib.
From the book: “Line plot • Scatter plot • Histogram • Box plot • Bar chart and • Pie chart”
How will you install Matplotlib?
Try it, then show the answerAnswer
Install Matplotlib using pip, the package manager for installing Python packages.
The chapter says Matplotlib can be installed using pip.
From the book: “You can install matplotlib using pip.”
Write the difference between the following functions: plt.plot([1,2,3,4]), plt. plot([1,2,3,4], [1,4,9,16]).
Try it, then show the answerAnswer
plt.plot([1,2,3,4]) uses the list as y values and automatically generates x values [0, 1, 2, 3]. plt.plot([1,2,3,4], [1,4,9,16]) uses the first list as x coordinates and the second list as y coordinates.
With a single list, Matplotlib generates the x sequence starting at zero. With two lists, the first two arguments provide the x and y coordinates.
From the book: “matplotlib assumes it is a sequence of y values, and automatically generates the x values for you.”
Part - IV — Answer the following questions (5 Marks)
Explain in detail the types of pyplots using Matplotlib.
Try it, then show the answerAnswer
Matplotlib is a popular data visualization library in Python that allows users to create two-dimensional charts. Its Pyplot provides several types of visualizations for presenting and comparing data.
- Line plot: A line chart displays data points called markers connected by straight line segments. It is often used to show trends over intervals of time.
- Scatter plot: A scatter plot shows data as a collection of points. Each point’s position depends on its two-dimensional value.
- Histogram: A histogram displays the frequency distribution of numerical data using bars. It is used for continuous variables, and there is no gap between its bars.
- Box plot: A box plot displays the distribution of data using the five-number summary: minimum, first quartile, median, third quartile and maximum.
- Bar chart: A bar chart represents categorical data with rectangular bars. It helps compare numerical values across categories, and its bars can be vertical or horizontal.
- Pie chart: A pie chart is a circular graphic divided into slices. It shows how parts relate to a whole and can display percentages.
Example: The chapter’s bar-chart example compares values for TAMIL, ENGLISH, MATHS, PHYSICS, CHEMISTRY and CS.
Thus, Matplotlib offers different plot types to present data clearly and suit different forms of comparison or distribution.
From the book: “The box plot is a standardized way of displaying the distribution of data based on the five number summary”
Explain the various buttons in a matplotlib window.
Try it, then show the answerAnswer
A Matplotlib window displays a graph and provides buttons to navigate, adjust, and save the figure. The buttons are located at the bottom-left corner of the output figure.
- Home Button: Click Home to return the chart to its original view after navigating it.
- Forward and Back Buttons: These buttons move to the previous view or forward again, like the buttons in a browser.
- Pan Axis Button: This button lets you click and drag the graph around.
- Zoom Button: Drag a square over the area to zoom in. A left-click and drag zooms in, while a right-click and drag can zoom out.
- Configure Subplots Button: This button adjusts various spacing options for the figure and plot.
- Save Figure Button: This button allows you to save the figure in different forms.
Example: In the two-line plot example, use the Home button to return to the original view after navigating the chart.
Together, these buttons help users navigate, zoom, configure, and save a Matplotlib figure.
From the book: “The Home Button will help once you have begun navigating your chart.”
Explain the purpose of the following functions: a. plt.xlabel b. plt.ylabel c. plt.title d. plt.legend() e. plt.show()
Try it, then show the answerAnswer
These Pyplot functions add labels and a title to a plot, provide a legend, and display the graph.
- a. plt.xlabel: Assigns a label to the x-axis.
- b. plt.ylabel: Assigns a label to the y-axis.
- c. plt.title: Assigns a title to the plot.
- d. plt.legend(): Invokes the default legend, which identifies the plotted lines.
- e. plt.show(): Displays the plot in a Matplotlib window.
Example: In the two-line plot, plt.xlabel('X-Axis'), plt.ylabel('Y-Axis'), plt.title('LINE GRAPH'), plt.legend(), and plt.show() are used.
Together, these functions label, identify, and display a plot.
From the book: “Using Matplotlib from within a Python script, you have to add plt.show() function inside the file to display your plot.”