Quiz: Python Plotting with Matplotlib

1. How do you plot a function y = f(x) after the statement import matplotlib.pyplot as plt?

A. plot(x,y)
Incorrect. Use plt.plot(x,y) instead to indicate that the plt package is used to create the plot.
B. plt(x,y)
Incorrect. Use plt.plot(x,y) to use the plot function.
C. matplotlib.plot(x,y)
Incorrect. Use plt.plot(x,y) with matplotlib.pyplot renamed as plt as a shortened name.
D. plt.plot(x,y)
E. plot(y,x)
Incorrect. Switch the x and y and use plt. at the beginning.

2. What is the symbol code for a black dashed line when plotting x and y?

A. plt.plot(x,y,'b-')
Incorrect. Blue solid line.
B. plt.plot(x,y,'k--')
Correct. Black dashed line.
C. plt.plot(x,y,'b--')
Incorrect. Blue bashed line.

3. Why is it important to create a plot with trends that can be distinguished without color? Other things like line style or width are needed to distinguish trends. Select all that apply.

A. Many people are color vision deficient.
Correct. There are an estimated 300 million people in the world with color vision deficiency. 1 in 12 men are color blind (8%). 1 in 200 women are color blind (0.5%).
B. Plots are often printed in black in white.
C. Plots are often displayed in color on screens.
Incorrect. That statement is true, but does not explain why plots should be distinguished without color.