0
0
Data Analysis Pythondata~10 mins

Labels, titles, and legends in Data Analysis Python - 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.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("My Plot Title")
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Bxlabel
Clegend
Dylabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using xlabel or ylabel instead of title.
Trying to use legend to set the title.
2fill in blank
medium

Complete the code to add a label to the x-axis.

Data Analysis Python
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'
Atitle
Blegend
Cylabel
Dxlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using ylabel instead of xlabel.
Trying to set the label with title or legend.
3fill in blank
hard

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

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6], label='Line 1')
plt.[1]()
plt.show()
Drag options to blanks, or click blank then click option'
Alegends
Blabel
Clegend
Dlegend_show
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'legends' instead of 'legend'.
Trying to call 'label()' to show the legend.
4fill in blank
hard

Fill both blanks to add labels to both axes.

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]("Days")
plt.[2]("Sales")
plt.show()
Drag options to blanks, or click blank then click option'
Axlabel
Btitle
Cylabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping xlabel and ylabel.
Using title or legend instead of axis labels.
5fill in blank
hard

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

Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6], label='Revenue')
plt.[1]("Monthly Revenue")
plt.[2]("Month")
plt.[3]()
Drag options to blanks, or click blank then click option'
Axlabel
Blegend
Ctitle
Dylabel
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up title and xlabel.
Forgetting parentheses on legend.
Using ylabel instead of xlabel.