Recall & Review
beginner
What function in matplotlib is commonly used to plot multiple lines on the same graph?
The
plt.plot() function can be called multiple times before plt.show() to plot multiple lines on the same graph.Click to reveal answer
beginner
How can you add a legend to a plot with multiple lines in matplotlib?
Use the
label parameter in plt.plot() for each line, then call plt.legend() to display the legend.Click to reveal answer
beginner
What is the purpose of calling
plt.show() after plotting multiple lines?plt.show() displays the figure window with all plotted lines. Without it, the plot may not appear.Click to reveal answer
intermediate
How do you change the color and style of each line when plotting multiple lines?
You can pass color and style arguments like
color='red' or linestyle='--' inside plt.plot() for each line.Click to reveal answer
beginner
Why is it useful to plot multiple lines on the same graph?
Plotting multiple lines helps compare different data sets or trends visually in one place, making it easier to analyze relationships.
Click to reveal answer
Which matplotlib function is used to plot lines on a graph?
✗ Incorrect
plt.plot() is used for line plots, while others are for bars, scatter points, or histograms.
How do you add a label for a line to appear in the legend?
✗ Incorrect
Labels are set inside plt.plot() with the label argument.
What does
plt.show() do?✗ Incorrect
plt.show() opens the window showing the plot.
Which argument changes the line style in
plt.plot()?✗ Incorrect
linestyle changes the pattern of the line (solid, dashed, etc.).
Why plot multiple lines on the same graph?
✗ Incorrect
Multiple lines help compare trends or values side by side.
Explain how to plot two different lines on the same graph using matplotlib.
Think about calling the plot function multiple times before showing the plot.
You got /3 concepts.
Describe how to customize the color and style of multiple lines in a matplotlib plot.
Each plt.plot() call can have its own style settings.
You got /3 concepts.