Challenge - 5 Problems
Spine Chart Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a basic spine chart plot
What will be the output of the following Python code using matplotlib to create a spine chart?
Matplotlib
import matplotlib.pyplot as plt import numpy as np labels = ['A', 'B', 'C', 'D'] values = [10, 15, 7, 12] fig, ax = plt.subplots() ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.spines['left'].set_position(('outward', 10)) ax.spines['bottom'].set_position(('outward', 10)) ax.plot(labels, values, marker='o') plt.show()
Attempts:
2 left
💡 Hint
Look at which spines are set visible and their positions.
✗ Incorrect
The code hides the top and right spines, and moves the left and bottom spines outward by 10 points. The plot is a line plot with markers connecting the points labeled A to D.
❓ data_output
intermediate1:30remaining
Number of visible spines after customization
After running this code, how many spines are visible on the plot?
Matplotlib
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.spines['left'].set_visible(True) ax.spines['bottom'].set_visible(True) plt.show()
Attempts:
2 left
💡 Hint
Check which spines are set to visible True or False.
✗ Incorrect
Only the left and bottom spines are visible; top and right are hidden.
🔧 Debug
advanced2:00remaining
Identify the error in spine position setting
What error will this code raise when trying to set spine position?
Matplotlib
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.spines['left'].set_position('outward', 10) plt.show()
Attempts:
2 left
💡 Hint
Check the method signature for set_position in matplotlib spines.
✗ Incorrect
The set_position method expects a single argument which can be a string or a tuple. Passing two separate arguments causes a TypeError.
❓ visualization
advanced2:00remaining
Effect of spine position on plot appearance
Which option best describes the visual effect of setting the bottom spine position to ('axes', 0.5)?
Matplotlib
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.spines['bottom'].set_position(('axes', 0.5)) ax.plot([0, 1], [0, 1]) plt.show()
Attempts:
2 left
💡 Hint
The 'axes' coordinate system ranges from 0 (bottom) to 1 (top) vertically.
✗ Incorrect
Setting position to ('axes', 0.5) moves the spine to the vertical center of the axes area.
🧠 Conceptual
expert1:30remaining
Purpose of spine customization in data visualization
Why would a data scientist customize spines in a plot? Choose the best reason.
Attempts:
2 left
💡 Hint
Think about how visual design affects understanding of data.
✗ Incorrect
Customizing spines helps highlight key axes and remove unnecessary lines, making plots clearer and easier to read.