0
0
Matplotlibdata~10 mins

Why image handling matters in Matplotlib - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library used for image plotting.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Amatplotlib.pyplot
Bpandas
Cseaborn
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy or pandas instead of matplotlib.pyplot.
Using seaborn which is for statistical plots, not basic image plotting.
2fill in blank
medium

Complete the code to load an image file named 'photo.png' using matplotlib.

Matplotlib
image = plt.[1]('photo.png')
Drag options to blanks, or click blank then click option'
Aimread
Bshow
Cplot
Dimshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using imshow which displays but does not load the image.
Using plot which is for line plots, not images.
3fill in blank
hard

Fix the error in the code to display the loaded image correctly.

Matplotlib
plt.[1](image)
plt.show()
Drag options to blanks, or click blank then click option'
Aplot
Bread
Cimshow
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot which is for line graphs, not images.
Using read or load which are not matplotlib functions.
4fill in blank
hard

Fill both blanks to create a dictionary with image filenames as keys and their sizes as values.

Matplotlib
sizes = {file: image.[1] for file in files if image.[2] > 1000}
Drag options to blanks, or click blank then click option'
Ashape
Bsize
Cndim
Ddtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using ndim which only gives the number of dimensions, not size.
Using dtype which gives data type, not size.
5fill in blank
hard

Fill all three blanks to filter images by width and create a dictionary of their heights.

Matplotlib
heights = {file: image.shape[[1]] for file, image in images.items() if image.shape[[2]] [3] 500}
Drag options to blanks, or click blank then click option'
A0
B1
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up height and width indices.
Using less than instead of greater than for filtering.