Bird
0
0

Which of the following is the correct way to overlay a red scatter plot on an image using matplotlib?

easy📝 Syntax Q12 of 15
Matplotlib - Image Display
Which of the following is the correct way to overlay a red scatter plot on an image using matplotlib?
A<pre>plt.scatter(x, y) plt.show() plt.imshow(image)</pre>
B<pre>plt.scatter(x, y, color='red') plt.imshow(image) plt.show()</pre>
C<pre>plt.imshow(image) plt.scatter(x, y, color='red') plt.show()</pre>
D<pre>plt.imshow(image, color='red') plt.scatter(x, y) plt.show()</pre>
Step-by-Step Solution
Solution:
  1. Step 1: Order of plotting matters

    The image must be shown first with plt.imshow() so that scatter points appear on top.
  2. Step 2: Correct syntax for scatter color

    Use color='red' inside plt.scatter() to make points red.
  3. Final Answer:

    plt.imshow(image) then plt.scatter(x, y, color='red') -> Option C
  4. Quick Check:

    Image first, then scatter with color [OK]
Quick Trick: Show image before scatter to overlay correctly [OK]
Common Mistakes:
  • Plotting scatter before image hides points
  • Passing color to imshow instead of scatter
  • Calling plt.show() too early

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes