Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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'.
✗ Incorrect
The pyplot module from matplotlib is used to create plots, including broken axes.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The breakaxes function from the breakaxes module creates plots with broken axes.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The y-values to plot must be passed to bax.plot as the second argument.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pyplot instead of breakaxes.
Using wrong y-limit ranges.
Not matching the import and function call names.
✗ Incorrect
Import breakaxes and use it to create the broken axes with the first y-limit range (0, 10).
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong import names.
Not setting the x-axis label correctly.
Confusing variable names for plotting.
✗ Incorrect
Import breakaxes and pyplot as plt. Set the x-axis label to 'Time'.