Challenge - 5 Problems
Broken Axes Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of broken axes plot code
What will be the output of the following Python code using matplotlib's broken axes?
Matplotlib
import matplotlib.pyplot as plt from brokenaxes import brokenaxes fig = plt.figure(figsize=(6,4)) bax = brokenaxes(ylims=((0, 1), (3, 4))) bax.plot([0, 1, 2, 3], [0.5, 0.7, 3.5, 3.8]) plt.show()
Attempts:
2 left
💡 Hint
Broken axes allow you to skip ranges on an axis to focus on important data segments.
✗ Incorrect
The brokenaxes function creates a plot with two separate y-axis ranges (0-1 and 3-4). The points are plotted accordingly, skipping the gap between 1 and 3.
❓ data_output
intermediateNumber of plotted points in broken axes
Given this code using brokenaxes, how many points will be visible on the plot?
Matplotlib
import matplotlib.pyplot as plt from brokenaxes import brokenaxes fig = plt.figure() bax = brokenaxes(ylims=((0, 2), (5, 7))) data_x = [0, 1, 2, 3, 4] data_y = [1, 1.5, 3, 6, 6.5] bax.plot(data_x, data_y) plt.show()
Attempts:
2 left
💡 Hint
Points outside the broken y-axis limits are not shown.
✗ Incorrect
The first two points (y=1, 1.5) fall within 0-2, and the last two (y=6, 6.5) within 5-7. The point at y=3 is outside both ranges and not shown, so 4 points are visible.
🔧 Debug
advancedIdentify the error in broken axes usage
What error will this code raise when trying to create a broken axes plot?
Matplotlib
import matplotlib.pyplot as plt from brokenaxes import brokenaxes fig = plt.figure() bax = brokenaxes(xlims=((0, 2), (1, 3))) bax.plot([0, 1, 2], [1, 2, 3]) plt.show()
Attempts:
2 left
💡 Hint
Check if the axis limit ranges overlap or are invalid.
✗ Incorrect
The x-axis limits overlap between (0,2) and (1,3), which is invalid and causes a ValueError.
🚀 Application
advancedUse case for broken axes in data visualization
Which scenario best fits using broken axes in a plot?
Attempts:
2 left
💡 Hint
Broken axes help when data has gaps or outliers that distort scale.
✗ Incorrect
Broken axes are useful to skip large gaps in data ranges and focus on important segments.
🧠 Conceptual
expertEffect of broken axes on data interpretation
What is a potential risk when using broken axes in plots?
Attempts:
2 left
💡 Hint
Think about how skipping axis ranges affects perception.
✗ Incorrect
Broken axes can hide gaps or differences in data, potentially misleading interpretation if not clearly indicated.
