Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the matplotlib library for plotting spine charts.
Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the whole matplotlib instead of pyplot.
Using unrelated libraries like pandas or numpy.
✗ Incorrect
We use matplotlib.pyplot as the standard module for plotting charts including spine charts.
2fill in blank
mediumComplete the code to create a figure and axis for plotting a spine chart.
Matplotlib
fig, ax = plt.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
plot() which draws lines but does not create figure and axis.Using
figure() alone which returns only the figure.✗ Incorrect
The subplots() function creates a figure and axes for plotting.
3fill in blank
hardFix the error in the code to set the spine color to red.
Matplotlib
ax.spines['bottom'].set_[1]('red')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
set_width which changes thickness, not color.Using
set_visible which hides or shows the spine.✗ Incorrect
The set_color() method changes the spine color.
4fill in blank
hardFill both blanks to hide the top and right spines of the plot.
Matplotlib
ax.spines['[1]'].set_visible(False) ax.spines['[2]'].set_visible(False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Hiding bottom or left spines instead of top or right.
Using
set_color instead of set_visible.✗ Incorrect
To hide the top and right spines, set their visibility to False.
5fill in blank
hardFill all three blanks to create a spine chart with custom spine positions.
Matplotlib
ax.spines['left'].set_position(('[1]', [2])) ax.spines['bottom'].set_position(('[3]', 0))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect position types like 'left' or 'right'.
Forgetting to provide the numeric value for the position.
✗ Incorrect
The left spine is moved outward by 10 points, and the bottom spine is positioned at the axes coordinate 0.