Recall & Review
beginner
What does
plt.plot(x, y) do in matplotlib?It creates a line plot by connecting points defined by the lists or arrays
x and y on the x-axis and y-axis respectively.Click to reveal answer
beginner
How do you add labels to the x-axis and y-axis in matplotlib?
Use
plt.xlabel('label') for the x-axis and plt.ylabel('label') for the y-axis to add descriptive labels.Click to reveal answer
beginner
What is the purpose of
plt.show()?It displays the plot window with all the current figures and plots. Without it, the plot might not appear in some environments.
Click to reveal answer
beginner
How can you change the line style and color in
plt.plot()?You can add a format string like
'r--' where 'r' is red color and '--' is dashed line. For example, plt.plot(x, y, 'r--').Click to reveal answer
beginner
What happens if you call
plt.plot() multiple times before plt.show()?All plots are drawn on the same figure, allowing you to overlay multiple lines or data sets in one graph.
Click to reveal answer
What does
plt.plot([1, 2, 3], [4, 5, 6]) do?✗ Incorrect
The first list is x values and the second is y values, connected by lines.
Which command adds a title to a matplotlib plot?
✗ Incorrect
Use
plt.title() to add a title to the plot.How do you display the plot after creating it?
✗ Incorrect
plt.show() opens the window with the plot.What does the format string 'g-.' mean in
plt.plot(x, y, 'g-.')?✗ Incorrect
'g' is green color, '-.' is dash-dot line style.
If you want to plot two lines on the same graph, what should you do?
✗ Incorrect
Multiple plt.plot() calls add lines to the same figure.
Explain how to create a simple line plot with labels for x and y axes using matplotlib.
Think about the steps to draw and display a plot with axis descriptions.
You got /4 concepts.
Describe how to customize the color and line style of a plot line in matplotlib.
Remember the short string codes like 'r--' for red dashed lines.
You got /3 concepts.