0
0
Matplotlibdata~10 mins

Pyplot interface overview 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 pyplot module from matplotlib.

Matplotlib
import matplotlib.[1] as plt
Drag options to blanks, or click blank then click option'
Acharts
Bgraph
Cplot
Dpyplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'plot' instead of 'pyplot'.
Trying to import 'charts' which does not exist.
2fill in blank
medium

Complete the code to create a simple line plot of y values.

Matplotlib
plt.[1]([1, 2, 3, 4], [10, 20, 25, 30])
plt.show()
Drag options to blanks, or click blank then click option'
Adraw
Bplot
Cline
Dgraph
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'draw' which is not a pyplot function.
Using 'line' which does not exist in pyplot.
3fill in blank
hard

Fix the error in the code to add a title to the plot.

Matplotlib
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('My Plot')
plt.show()
Drag options to blanks, or click blank then click option'
Aadd_title
Bset_title
Ctitle
Dplot_title
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set_title' which is for axes, not pyplot interface.
Using 'add_title' or 'plot_title' which do not exist.
4fill in blank
hard

Fill both blanks to label the x-axis and y-axis of the plot.

Matplotlib
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('Time')
plt.[2]('Speed')
plt.show()
Drag options to blanks, or click blank then click option'
Axlabel
Bylabel
Ctitle
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'title' instead of axis labels.
Using 'legend' which is for plot legends.
5fill in blank
hard

Fill all three blanks to create a scatter plot with red dots and show it.

Matplotlib
plt.[1]([5, 7, 8], [2, 3, 5], c=[2], marker=[3])
plt.show()
Drag options to blanks, or click blank then click option'
Aplot
B'red'
C'o'
Dscatter
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'plot' instead of 'scatter' for scatter plots.
Forgetting quotes around color and marker.