0
0
Matplotlibdata~10 mins

Broken axes concept in Matplotlib - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the module needed to create broken axes plots.

Matplotlib
import matplotlib.[1] as plt
Drag options to blanks, or click blank then click option'
Apyplot
Bfigure
Cbreakaxes
Daxes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'breakaxes' directly without importing pyplot.
Trying to import 'axes' which is not a module.
Importing 'figure' instead of 'pyplot'.
2fill in blank
medium

Complete the code to create a broken axes plot with two y-axis ranges.

Matplotlib
import [1]

fig, bax = [1].breakaxes(ylims=((0, 5), (15, 20)))
Drag options to blanks, or click blank then click option'
Abreakaxes
Bpyplot
Caxes
Dfigure
Attempts:
3 left
💡 Hint
Common Mistakes
Using pyplot.breakaxes which does not exist.
Trying to use axes.breakaxes which is invalid.
Using figure.breakaxes which is incorrect.
3fill in blank
hard

Fix the error in the code to plot data on broken axes.

Matplotlib
fig, bax = breakaxes(ylims=((0, 3), (10, 15)))
x = [1, 2, 3, 4]
y = [2, 1, 12, 14]
bax.plot(x, [1])
plt.show()
Drag options to blanks, or click blank then click option'
Ax
Bbax
Cy
Dfig
Attempts:
3 left
💡 Hint
Common Mistakes
Passing x instead of y to plot.
Passing fig or bax which are not data arrays.
Not passing any data to plot.
4fill in blank
hard

Fill both blanks to create a broken axes plot with two y-axis ranges and plot data.

Matplotlib
from breakaxes import [1]

fig, bax = [1](ylims=([2], (20, 30)))
x = [1, 2, 3, 4]
y = [2, 25, 27, 29]
bax.plot(x, y)
plt.show()
Drag options to blanks, or click blank then click option'
Abreakaxes
Bpyplot
C(0, 10)
D(10, 20)
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pyplot instead of breakaxes.
Using wrong y-limit ranges.
Not matching the import and function call names.
5fill in blank
hard

Fill all three blanks to create a broken axes plot, plot data, and set labels.

Matplotlib
from breakaxes import [1]
import matplotlib.pyplot as [2]

fig, bax = [1](ylims=((0, 5), (15, 25)))
x = [1, 2, 3, 4]
y = [3, 4, 20, 22]
bax.plot(x, y)
bax.set_xlabel('[3]')
bax.set_ylabel('Value')
plt.show()
Drag options to blanks, or click blank then click option'
Abreakaxes
Bplt
CTime
Dax
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong import names.
Not setting the x-axis label correctly.
Confusing variable names for plotting.