Challenge - 5 Problems
Master of Titles and Labels
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the title of the plot?
Look at the code below. What will be the title shown on the plot?
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.title('Sales Over Time') plt.xlabel('Month') plt.ylabel('Revenue') plt.show()
Attempts:
2 left
💡 Hint
The title is set by plt.title() function.
✗ Incorrect
The plt.title() function sets the main title of the plot. Here, it is 'Sales Over Time'.
❓ Predict Output
intermediate1:30remaining
What is the label of the x-axis?
What label will appear on the x-axis in the plot below?
Matplotlib
import matplotlib.pyplot as plt plt.plot([10, 20, 30], [1, 4, 9]) plt.title('Growth Chart') plt.xlabel('Time (years)') plt.ylabel('Value') plt.show()
Attempts:
2 left
💡 Hint
The x-axis label is set by plt.xlabel().
✗ Incorrect
The plt.xlabel() function sets the label for the x-axis. Here, it is 'Time (years)'.
🔧 Debug
advanced2:00remaining
Why does this code not show the y-axis label?
The code below is supposed to show a y-axis label, but it does not appear. What is the problem?
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [3, 2, 1]) plt.title('Sample Plot') plt.xlabel('X Axis') plt.ylabel('') plt.show()
Attempts:
2 left
💡 Hint
Check the argument passed to plt.ylabel().
✗ Incorrect
The y-axis label is set to an empty string '', so no label appears on the y-axis.
❓ data_output
advanced2:00remaining
What are the axis labels after this code?
After running the code below, what are the labels of the x-axis and y-axis?
Matplotlib
import matplotlib.pyplot as plt plt.plot([5, 10, 15], [2, 4, 6]) plt.xlabel('Distance (km)') plt.ylabel('Speed (km/h)') plt.xlabel('Time (seconds)') plt.show()
Attempts:
2 left
💡 Hint
The last plt.xlabel() call overwrites the previous one.
✗ Incorrect
The second plt.xlabel('Time (seconds)') replaces the first x-axis label. The y-axis label remains 'Speed (km/h)'.
🧠 Conceptual
expert1:30remaining
Why is it important to label axes and add titles in plots?
Choose the best reason why adding titles and axis labels is important in data visualization.
Attempts:
2 left
💡 Hint
Think about how someone else reads your plot.
✗ Incorrect
Titles and axis labels explain what the data shows and what each axis means, making the plot clear and easy to understand.