Arrange the following steps to create a frequency polygon using matplotlib.
A. import matplotlib.pyplot as plt
B. Add labels, title and display the plot
C. Create data and generate frequency count
D. Use plt.plot with frequency count as y-axis
Arrange the following steps to create a frequency polygon using matplotlib.
A. import matplotlib.pyplot as plt
B. Add labels, title and display the plot
C. Create data and generate frequency count
D. Use plt.plot with frequency count as y-axis
Solution
The import must come first, then the data and frequency count, then the plot, and finally the labels and display. Each step depends on the one before it.
A. import matplotlib.pyplot as plt, so that the plotting functions are available.
C. Create data and generate frequency count, so there are values to plot.
D. Use plt.plot with frequency count as y-axis, which draws the polygon.
B. Add labels, title and display the plot, which is done after the plot exists, ending with plt.show().
Options 1 and 2: the plot is drawn (D) or labelled (B) before the data and frequency count (C) exist, so there is nothing to plot.
Option 4: it uses plt before importing it (A), which gives an error.
Related questions:
2026: 11 May Shift 2
2025: 27 May Shift 2