What is the purpose of the plt.twinx() function in Matplotlib?
-
A
To create a twin subplot sharing the y-axis
-
B
To create a twin subplot sharing the x-axis
-
C
To create a new figure
-
D
To create a secondary y-axis
Correct answer
Correct answer
D. To create a secondary y-axis
15 views
Explanation
plt.twinx() creates a second y-axis that shares the same x-axis, which lets you plot two datasets with different y-scales on one figure.
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ