How to make IPython notebook matplotlib plot inline
To make matplotlib plots show up inline in an IPython notebook, you can use the following code snippet:
To make matplotlib plots show up inline in an IPython notebook, you can use the following code snippet:
Make matplotlib plots show up inline in an IPython notebook
%matplotlib inline
<div class="alert alert-info flex not-prose">![]()
<span class="hidden md:block">Watch a video course</span>Python - The Practical Guide</div>
You should place this code at the beginning of your notebook before creating any plots. This will configure matplotlib to display plots directly in the output cells of the notebook, rather than in separate windows.
Display plots directly in the output cells of the notebook
import matplotlib.pyplot as plt
%matplotlib inline
# Create a plot
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()This will generate the plot inline in the output cell