Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new figure using matplotlib.
Data Analysis Python
import matplotlib.pyplot as plt fig = plt.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.plot() instead of plt.figure()
Trying to call plt.show() to create a figure
✗ Incorrect
The figure() function creates a new figure object in matplotlib.
2fill in blank
mediumComplete the code to add a single axes to the figure.
Data Analysis Python
fig = plt.figure() ax = fig.[1](111)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using add_axes() with a code instead of a rectangle
Calling subplot() directly on plt instead of on fig
✗ Incorrect
The add_subplot() method adds an axes to the figure using a 3-digit code.
3fill in blank
hardFix the error in the code to create a figure and axes correctly.
Data Analysis Python
fig, ax = plt.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.figure() which returns only one object
Using plt.subplot() which returns a single axes
✗ Incorrect
The subplots() function returns both a figure and axes objects.
4fill in blank
hardFill both blanks to create a figure with 2 rows and 1 column of subplots.
Data Analysis Python
fig, ax = plt.[1]([2], 1)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.figure() instead of plt.subplots()
Swapping rows and columns numbers
✗ Incorrect
plt.subplots(2, 1) creates a figure with 2 rows and 1 column of axes.
5fill in blank
hardFill all three blanks to create a figure with 3 columns and 2 rows of subplots.
Data Analysis Python
fig, ax = plt.[1]([2], [3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping rows and columns numbers
Using plt.figure() instead of plt.subplots()
✗ Incorrect
plt.subplots(2, 3) creates a figure with 2 rows and 3 columns of axes.