Bird
0
0

Which of the following is the correct syntax to display an image stored in variable img using matplotlib.pyplot?

easy📝 Syntax Q3 of 15
Matplotlib - Image Display
Which of the following is the correct syntax to display an image stored in variable img using matplotlib.pyplot?
Aplt.imshow(img)
Bplt.show(img)
Cplt.image(img)
Dplt.plot(img)
Step-by-Step Solution
Solution:
  1. Step 1: Recall matplotlib image display function

    The function to display images is imshow() in matplotlib.pyplot.
  2. Step 2: Check syntax correctness

    plt.imshow(img) correctly displays the image stored in img.
  3. Final Answer:

    plt.imshow(img) -> Option A
  4. Quick Check:

    Image display syntax = plt.imshow(img) [OK]
Quick Trick: Use plt.imshow() to show images in matplotlib [OK]
Common Mistakes:
  • Using plt.show(img) which only shows the plot window
  • Using plt.image() which does not exist
  • Using plt.plot() which is for line plots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes