I am having trouble understanding the use of %Matplotlib inline in my jupyter notebook.
My understanding is that I need to run %Matplotlib inline so that I can display the plots in the jupyter notebook instead of a popped up window. However, it looks like I can still display the plot without having the need to run %Matplotlib inline.
May I know why? Or is it that we dont need to run %Matplotlib anymore? Thank you so much in advance.
import matplotlib.pyplot as plt
import pandas as pd
unrate = pd.read_csv(‘unrate.csv’)
unrate[‘DATE’] = pd.to_datetime(unrate[‘DATE’])
first_twelve = unrate[:12]
This is probably the best and most detailed answer to your question.
%matplotlib inline sets the backend of matplotlib to the ‘inline’ backend.
I have kind of the same question as the one from @4voomshakalaka , and I read the stackoverflow thread, and it’s still not clear to me.
There is an illustration on the post that is supposed to show the difference between the case with
%matplotlib inline and without. However, when I test on my side, either locally or on the dataquest jupyter notebook, I don’t see any differences and the plot always appear next to the cell.
Your question might be best suited as a separate post.
However, if you used
%matplotlib inline once already, then the backend for your Notebook is set. So, if you remove and re-run the code, it doesn’t change anything.
You will have to restart the Kernel in order to see what affect not having
%matplotlib inline has when creating plots.
%matplotlib inline , your plots won’t be displayed after you run a particular code cell.