Recall & Review
beginner
What is a dual y-axis plot in matplotlib?
A dual y-axis plot shows two different y-axes on the same graph, each with its own scale. This helps compare two datasets with different units or ranges on one plot.
Click to reveal answer
beginner
Which matplotlib function creates a second y-axis sharing the same x-axis?
The
twinx() function creates a second y-axis on the right side of the plot that shares the same x-axis as the original plot.Click to reveal answer
beginner
Why use different colors for lines and y-axis labels in a dual y-axis plot?
Using different colors helps clearly link each line to its corresponding y-axis, making the plot easier to read and understand.
Click to reveal answer
beginner
How do you label the second y-axis in matplotlib?
After creating the second y-axis with
twinx(), use ax2.set_ylabel('label') to add a label to the right y-axis.Click to reveal answer
beginner
What is a common use case for dual y-axis plots?
They are useful when comparing two related datasets with different units or scales, like temperature and rainfall over time.
Click to reveal answer
Which matplotlib method creates a second y-axis sharing the same x-axis?
✗ Incorrect
The
twinx() method creates a second y-axis on the right side sharing the x-axis.Why use a dual y-axis plot?
✗ Incorrect
Dual y-axis plots help compare datasets with different units or scales on the same x-axis.
How do you label the second y-axis in matplotlib?
✗ Incorrect
After creating the second y-axis with
twinx(), use ax2.set_ylabel() to label it.What is a good practice to distinguish lines in a dual y-axis plot?
✗ Incorrect
Different colors help link each line to its y-axis, improving readability.
Which side of the plot does the second y-axis appear by default?
✗ Incorrect
The second y-axis created by
twinx() appears on the right side.Explain how to create a dual y-axis plot in matplotlib and why it is useful.
Think about plotting two lines with different units on one graph.
You got /4 concepts.
Describe best practices for making dual y-axis plots easy to read.
Consider how to help the viewer quickly understand which line belongs to which axis.
You got /4 concepts.