Bird
0
0

Which of the following is the correct way to display a 2D numpy array named img as an image using matplotlib?

easy📝 Syntax Q12 of 15
Matplotlib - Image Display
Which of the following is the correct way to display a 2D numpy array named img as an image using matplotlib?
Aplt.hist(img)
Bplt.plot(img)
Cplt.imshow(img)
Dplt.show(img)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the function to display images

    To show an image from a 2D array, plt.imshow() is the correct function.
  2. Step 2: Check other options for correctness

    plt.plot() is for line plots, plt.hist() for histograms, and plt.show() displays the current figure but does not take data as argument.
  3. Final Answer:

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

    Image display = plt.imshow() [OK]
Quick Trick: Use imshow to display arrays as images [OK]
Common Mistakes:
  • Using plt.plot for image data
  • Passing data to plt.show() incorrectly
  • Confusing histogram with image display

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes