0
0
Matplotlibdata~10 mins

Small multiples (facet grid) in Matplotlib - Interactive Code Practice

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

Complete the code to create a 2x2 grid of plots using matplotlib subplots.

Matplotlib
fig, axes = plt.subplots([1], 2)
plt.show()
Drag options to blanks, or click blank then click option'
A1
B3
C4
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 rows instead of 2.
Confusing rows and columns.
2fill in blank
medium

Complete the code to plot data on the first subplot in a 2x2 grid.

Matplotlib
fig, axes = plt.subplots(2, 2)
axes[[1], 0].plot([1, 2, 3], [4, 5, 6])
plt.show()
Drag options to blanks, or click blank then click option'
A2
B0
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of 0 for the first subplot.
Using an index out of range.
3fill in blank
hard

Fix the error in the code to create a facet grid with 3 rows and 1 column.

Matplotlib
fig, axes = plt.subplots([1], 1)
axes[0].plot([1, 2, 3], [3, 2, 1])
plt.show()
Drag options to blanks, or click blank then click option'
A3
B1
C2
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Setting rows to 1 instead of 3.
Confusing rows and columns.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Matplotlib
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length.
Using the word in the condition instead of its length.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts if count is greater than 0.

Matplotlib
result = { [1]: [2] for [3], [2] in data.items() if [2] > 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'item' instead of 'k' and 'v'.
Not converting keys to uppercase.
Using the wrong variable names.