Exit Chapter 03 ยท ๐Ÿ“Š Plotting with PyPlot โ€” Quiz

Playing as a guest? to earn XP and track your progress.

Question 1 of 50 0 correct so far

๐Ÿ“Š Plotting with PyPlot Quiz

Q1.

What is the primary purpose of Data Visualization?

Explanation

Data Visualization translates information into a visual context like a map or graph to make data easier for the human brain to understand and pull insights from.

Q2.

Which Python library serves as the foundation for many visualization libraries and provides 2D plotting capabilities?

Explanation

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python and serves as the foundation for others.

Q3.

Which module within Matplotlib provides a state-machine interface mimicking MATLAB?

Explanation

Pyplot is the specific module that provides a state-machine interface to the underlying plotting library, mimicking MATLAB.

Q4.

In Matplotlib architecture, what is considered the top-level container for all plot elements?

Explanation

The Figure is the top-level container, acting as the canvas or window where the graph and its components are drawn.

Q5.

What is the region of the figure where the data is actually plotted?

Explanation

The Axes is the region of the figure where data is plotted. It contains the X-axis and Y-axis.

Q6.

What is the function of the 'Axis' object in a plot?

Explanation

The Axis objects are number-line-like objects that handle the scale and limits of the graph, generating ticks and tick labels.

Q7.

Which element identifies what different colors or line styles represent in a plotted data series?

Explanation

A Legend is an area describing the elements of the graph, identifying what different colors or line styles represent.

Q8.

What chart type is best used to show the frequency distribution of continuous data?

Explanation

A Histogram is a graphical representation of the frequency distribution of a set of continuous data using bins.

Q9.

Which of the following displays data based on a five-number summary including quartiles?

Explanation

A Box Plot is a standardized way of displaying data distribution based on the minimum, Q1, median, Q3, and maximum.

Q10.

Which layer of Matplotlib handles the rendering of the plot to a file or screen?

Explanation

The Backend Layer handles the rendering of the plot to a file or screen (e.g., PNG, PDF).

Q11.

What is the standard convention for importing the pyplot module?

Explanation

Standard convention dictates using the alias plt (or sometimes pl) for matplotlib.pyplot.

Q12.

Which function is used to create a standard line chart?

Explanation

plt.plot() is the function used for creating line charts.

Q13.

If you run plt.plot([10, 20, 30]), what will be the X-axis values?

Explanation

If only one list is provided, Matplotlib assumes they are Y-values and automatically generates X-values starting from 0 ([0, 1, 2]).

Q14.

Which function is used to display the final graph to the user?

Explanation

plt.show() is used to display the final graph.

Q15.

How do you set the size of a figure in Matplotlib?

Explanation

The size of the figure is controlled using plt.figure(figsize=(width, height)).

Q16.

Which function turns on the grid lines for a plot?

Explanation

plt.grid(True) turns on the grid lines for both axes.

Q17.

In plt.plot(), which argument changes the line thickness?

Explanation

The linewidth (or lw) argument changes the thickness of the line.

Q18.

Which argument is used to specify the line style as dashed?

Explanation

The linestyle (or ls) argument controls the style. '--' or 'dashed' represents a dashed line.

Q19.

What does the 'marker' argument do in a plot command?

Explanation

The marker argument adds a symbol (like a dot or star) to represent a specific data point.

Q20.

Which function is primarily used to observe correlations between two variables without connecting lines?

Explanation

A scatter plot (plt.scatter()) displays data points without connecting lines and is used to observe relationships or correlations.

Q21.

Which function creates a vertical bar chart?

Explanation

plt.bar() creates a vertical bar chart.

Q22.

Which function creates a horizontal bar chart?

Explanation

plt.barh() is used to create a horizontal bar chart.

Q23.

What must be done to plot multiple bar charts side-by-side?

Explanation

To plot multiple data series in bar charts, the X-coordinates of the bars must be offset manually so they do not overlap.

Q24.

In a pie chart, which parameter is used to display the percentage value on the slices?

Explanation

The autopct parameter is used to display the percentage value on the slices.

Q25.

Which pie chart parameter allows separating a slice from the main pie?

Explanation

The explode parameter allows separating a slice from the main pie to highlight it.

Q26.

Which function sets the title of the chart?

Explanation

plt.title() sets the chart title.

Q27.

How do you set the label for the X-axis?

Explanation

plt.xlabel() sets the label for the X-axis.

Q28.

To display a legend, what argument must be included in the plot function?

Explanation

plt.legend() requires label arguments in the plot function to identify the series.

Q29.

Which function saves the current figure to a file?

Explanation

plt.savefig() is used to save the graph to a storage device.

Q30.

Why should plt.savefig() be called before plt.show()?

Explanation

Always call plt.savefig() before plt.show() because show() resets the canvas/flushes the buffer, resulting in a blank saved image if called after.

Q31.

Which argument defines the number of intervals in a histogram?

Explanation

The bins argument defines the number of intervals or ranges in a histogram.

Q32.

What is the key visual difference between a Bar Chart and a Histogram?

Explanation

Histograms show continuous data distribution and usually have no gaps between bars, whereas Bar charts show discrete categories and usually have gaps.

Q33.

A Frequency Polygon is similar to a histogram but uses what to connect midpoints?

Explanation

A frequency polygon uses lines to join the midpoints of each interval (bin) at their respective heights.

Q34.

In a Box Plot, what does the box itself represent?

Explanation

The box in a box plot represents the Interquartile Range (IQR), from Q1 to Q3.

Q35.

Which method allows you to plot directly from a Pandas DataFrame?

Explanation

The built-in wrapper df.plot() allows plotting directly from a Pandas DataFrame.

Q36.

What color does the code 'k' represent in Matplotlib?

Explanation

The color code 'k' represents Black.

Q37.

What color does the code 'w' represent in Matplotlib?

Explanation

The color code 'w' represents White.

Q38.

Which marker code represents a square?

Explanation

The marker code 's' represents a Square.

Q39.

Which marker code represents a circle?

Explanation

The marker code 'o' is used for a Circle.

Q40.

What is the default line style in Matplotlib?

Explanation

The default line style is 'solid' or '-'.

Q41.

Which kind argument would you use in df.plot() to create a scatter plot?

Explanation

You use kind='scatter' in df.plot() to create a scatter plot.

Q42.

What happens if you try to pass linestyle to plt.scatter()?

Explanation

Scatter plots do not have connecting lines, so linestyle is invalid or ignored.

Q43.

What error occurs if the lists passed to plt.plot(x, y) have different lengths?

Explanation

Matplotlib raises a ValueError (x and y must have same first dimension) if the lists have different lengths.

Q44.

Which command manually sets the limits of the Y-axis?

Explanation

plt.ylim() is used to manually set the range/limits of the Y-axis.

Q45.

Which plot type implies data continuity?

Explanation

A line chart connects data points, implying continuity between them.

Q46.

What does the width parameter control in plt.bar()?

Explanation

The width parameter controls the thickness of the bars.

Q47.

Which plot helps specifically in identifying outliers?

Explanation

Box plots explicitly display outliers as individual points outside the whiskers.

Q48.

What is the correct syntax to install Matplotlib via command line?

Explanation

The standard command is pip install matplotlib.

Q49.

In a histogram, if bins is a sequence (list), what does it define?

Explanation

If bins is a sequence, it defines the specific bin edges.

Q50.

What is the alias for triangle up marker?

Explanation

The marker code '^' represents a Triangle Up.