0
0
Matplotlibdata~10 mins

3D scatter plots 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'
AAxes2D
BAxes3D
Cscatter3d
Dplot3d
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'plot3d' which is not a valid import.
Confusing 2D and 3D axes names.
2fill in blank
medium

Complete the code to create a 3D subplot in matplotlib.

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

Fix the error in the code to plot a 3D scatter plot with x, y, z data.

Matplotlib
ax.scatter([1], y, z)
Drag options to blanks, or click blank then click option'
Az
B[x]
CX
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'X' which is undefined.
Passing a list with brackets which is unnecessary.
Passing 'z' instead of 'x' for the x-axis.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.

Matplotlib
{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 length of the whole list.
5fill in blank
hard

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

Matplotlib
{ [1]: [2] for k, v in data.items() if [3] }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Cv > 0
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of uppercase.
Filtering with k > 0 which compares string to number.
Mapping keys to keys instead of values.