0
0
Matplotlibdata~10 mins

3D bar charts 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 import the 3D plotting toolkit from matplotlib.

Matplotlib
from mpl_toolkits.mplot3d import [1]
Drag options to blanks, or click blank then click option'
Aplot3d
BAxes3D
Cbar3d
Dfigure3d
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import plot3d instead of Axes3D.
Using bar3d which is a method, not a class.
Importing figure3d which does not exist.
2fill in blank
medium

Complete the code to create a 3D axes object from a matplotlib figure.

Matplotlib
fig = plt.figure()
ax = fig.add_subplot(111, projection=[1])
Drag options to blanks, or click blank then click option'
A'2d'
B'xyz'
C'3D'
D'3d'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase '3D' instead of lowercase '3d'.
Using '2d' which creates a 2D plot.
Using 'xyz' which is not a valid projection.
3fill in blank
hard

Fix the error in the code to plot a 3D bar chart with correct bar widths.

Matplotlib
ax.bar3d(x, y, z, [1], dy, dz, color='blue')
Drag options to blanks, or click blank then click option'
Adx
Bx
Cwidth
Dheight
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'x' instead of 'dx' for width.
Using 'width' or 'height' which are not parameter names.
Confusing dy and dz with dx.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length 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 > 3
Dlen(words) > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using word > 3 which compares a string to a number.
Using len(words) > 3 which checks the whole list length.
Putting the condition in the wrong place.
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 1.

Matplotlib
result = [1]: [2] for [3], [2] in data.items() if [2] > 1
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using data instead of word in the loop.
Using word instead of count in the value.
Not filtering counts greater than 1.