0
0
Matplotlibdata~20 mins

Inline display in Jupyter notebooks in Matplotlib - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Inline Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this matplotlib inline code?
Consider this code run in a Jupyter notebook cell:
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot([1, 2, 3], [4, 5, 6])
plt.title('Simple Line Plot')
plt.show()

What will be displayed after running this cell?
Matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot([1, 2, 3], [4, 5, 6])
plt.title('Simple Line Plot')
plt.show()
AA static line plot image with points (1,4), (2,5), (3,6) and the title 'Simple Line Plot' shown below the code cell.
BAn interactive plot window pops up outside the notebook showing the line plot.
CNo plot is shown because plt.show() is missing.
DA blank output with no plot or title is displayed.
Attempts:
2 left
💡 Hint
Think about what %matplotlib inline does in Jupyter notebooks.
🧠 Conceptual
intermediate
1:30remaining
Why use '%matplotlib inline' in Jupyter notebooks?
What is the main purpose of running the command %matplotlib inline in a Jupyter notebook?
ATo save plots automatically to disk without displaying them.
BTo enable interactive plot windows outside the notebook.
CTo disable all matplotlib plotting in the notebook.
DTo make matplotlib plots display as static images inside the notebook cells.
Attempts:
2 left
💡 Hint
Think about how plots appear by default in Jupyter notebooks.
🔧 Debug
advanced
2:00remaining
Why does this plot not display inline in Jupyter?
You run this code in a Jupyter notebook:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.title('Test Plot')

No plot appears below the cell. What is the most likely reason?
Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.title('Test Plot')
AThe magic command %matplotlib inline was not run, so plots do not display inline automatically.
BThe plt.show() function is missing, so the plot is not rendered.
CThe plot data is invalid, so nothing is drawn.
DThe title function must be called before plot to display the title.
Attempts:
2 left
💡 Hint
Think about how matplotlib behaves in Jupyter without any magic commands.
data_output
advanced
1:30remaining
What is the output type when using inline matplotlib plots?
When you run matplotlib plotting commands with %matplotlib inline in a Jupyter notebook, what type of output is generated and displayed?
AA vector graphic file saved to disk automatically.
BA pop-up interactive window outside the notebook.
CA PNG image embedded as output below the code cell.
DA text description of the plot printed in the output.
Attempts:
2 left
💡 Hint
Think about how images appear inside notebook cells.
🚀 Application
expert
2:30remaining
How to switch from inline to interactive matplotlib plots in Jupyter?
You want to switch from static inline matplotlib plots to interactive plots inside your Jupyter notebook. Which command should you run?
A%matplotlib inline
B%matplotlib notebook
C%matplotlib qt
D%matplotlib widget
Attempts:
2 left
💡 Hint
Think about which magic command enables interactive plots inside or outside the notebook.