0
0
Matplotlibdata~10 mins

Label, title, and axis names 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 add a title to the plot.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("My Plot")
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Bxlabel
Cylabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Using xlabel or ylabel instead of title.
Forgetting to call plt.show() to display the plot.
2fill in blank
medium

Complete the code to label the x-axis.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("Time (seconds)")
plt.show()
Drag options to blanks, or click blank then click option'
Axlabel
Btitle
Cylabel
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using ylabel instead of xlabel.
Using title instead of xlabel.
3fill in blank
hard

Fix the error in labeling the y-axis.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("Speed (m/s)")
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Bplot
Cxlabel
Dylabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using xlabel instead of ylabel.
Using title instead of ylabel.
4fill in blank
hard

Fill both blanks to add a title and label the x-axis.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("Sales Over Time")
plt.[2]("Months")
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Bxlabel
Cylabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping xlabel and ylabel.
Using legend instead of title or xlabel.
5fill in blank
hard

Fill all three blanks to add a title, label the x-axis, and label the y-axis.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("Temperature Change")
plt.[2]("Day")
plt.[3]("Degrees Celsius")
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Bxlabel
Cylabel
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up xlabel and ylabel.
Using grid instead of labels.