0
0
Matplotlibdata~10 mins

Title and axis labels 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 as 'Time'.

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

Fix the error in the code to label the y-axis as 'Speed'.

Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('Speed')
plt.show()
Drag options to blanks, or click blank then click option'
Axlabel
Btitle
Cylabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'legends' instead of 'legend'.
Using xlabel or 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]("Year")
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 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'
Axlabel
Bylabel
Ctitle
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up xlabel and ylabel.
Using legend instead of axis labels.