0
0
Matplotlibdata~10 mins

Why the OO interface 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 create a figure and axes using the object-oriented interface.

Matplotlib
fig, ax = plt.[1]()
Drag options to blanks, or click blank then click option'
Afigure
Bshow
Cplot
Dsubplots
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.figure() returns only the figure, not axes.
Using plt.plot() creates a plot but does not return figure and axes objects.
Using plt.show() just displays the plot and does not create objects.
2fill in blank
medium

Complete the code to plot data using the axes object in the OO interface.

Matplotlib
ax.[1](x, y)
Drag options to blanks, or click blank then click option'
Aplot
Bfigure
Cshow
Dsubplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using ax.figure() does not plot data.
Using ax.show() only displays the plot but does not plot data.
Using ax.subplot() is not a valid method.
3fill in blank
hard

Fix the error in setting the title using the OO interface.

Matplotlib
ax.[1]('My Plot Title')
Drag options to blanks, or click blank then click option'
Atitle
Blabel
Cset_title
Dsetlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using ax.title() causes an error because it does not exist.
Using ax.setlabel() or ax.label() are invalid for titles.
4fill in blank
hard

Fill both blanks to create a scatter plot and set x and y labels using the OO interface.

Matplotlib
ax.[1](x, y)
ax.[2]('X axis')
ax.set_ylabel('Y axis')
Drag options to blanks, or click blank then click option'
Ascatter
Bset_xlabel
Cplot
Dxlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using ax.plot() instead of ax.scatter() changes the plot type.
Using ax.xlabel() instead of ax.set_xlabel() causes an error.
5fill in blank
hard

Fill all three blanks to create a bar chart, set the title, and display the plot using the OO interface.

Matplotlib
fig, ax = plt.subplots()
ax.[1](categories, values)
ax.[2]('Category Counts')
plt.[3]()
Drag options to blanks, or click blank then click option'
Abar
Bset_title
Cshow
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using ax.plot() instead of ax.bar() changes the chart type.
Using ax.title() instead of ax.set_title() causes an error.
Forgetting plt.show() means the plot won't display.