0
0
Matplotlibdata~20 mins

Broken axes concept in Matplotlib - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Broken Axes Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output 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()
AA plot with two x-axis segments broken at 1 and 2, but continuous y-axis.
BA single continuous y-axis from 0 to 4 with all points plotted normally.
CA plot with two y-axis segments: one from 0 to 1 and another from 3 to 4, showing points connected across the break.
DA runtime error because brokenaxes does not support multiple y-axis limits.
Attempts:
2 left
💡 Hint
Broken axes allow you to skip ranges on an axis to focus on important data segments.
data_output
intermediate
1:30remaining
Number 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()
A2 points
B3 points
C5 points
D4 points
Attempts:
2 left
💡 Hint
Points outside the broken y-axis limits are not shown.
🔧 Debug
advanced
2:00remaining
Identify 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()
ASyntaxError because of wrong tuple format
BValueError due to overlapping x-axis limits
CNo error, plot shows two broken x-axis segments
DTypeError because brokenaxes does not support xlims parameter
Attempts:
2 left
💡 Hint
Check if the axis limit ranges overlap or are invalid.
🚀 Application
advanced
1:30remaining
Use case for broken axes in data visualization
Which scenario best fits using broken axes in a plot?
ADisplaying data with a large gap in y-values to focus on two separate ranges.
BVisualizing data with only one small range of values.
CCreating a pie chart to show proportions.
DPlotting continuous data with no gaps or outliers.
Attempts:
2 left
💡 Hint
Broken axes help when data has gaps or outliers that distort scale.
🧠 Conceptual
expert
2:30remaining
Effect of broken axes on data interpretation
What is a potential risk when using broken axes in plots?
AIt can mislead viewers by visually compressing or skipping data ranges, hiding true differences.
BIt always improves clarity without any drawbacks.
CIt causes plots to be unreadable due to overlapping axis labels.
DIt prevents plotting multiple lines on the same graph.
Attempts:
2 left
💡 Hint
Think about how skipping axis ranges affects perception.