问题
I am just trying to understand why my jupyter installation does not require me to run '%matplotlib inline' (which, according to everything I've read, I should have to run that to get my plots inline in my jupyter notebook). But the fact is, my matplotlib plots appear inline in my notebook whether I run '%matplotlib inline' or not. I am running an anaconda install of jupyter on ubuntu under WSL, using chrome as the client to my notebook server. jupyter --version 4.4.0 and jupyter-notebook --version 5.7.8
I've checked my ~/.jupyter/jupyter_notebook_config.py file and see nothing in there about matplotlib.
If I run the following in my notbook:
import matplotlib
matplotlib.get_backend()
This is the output:
'module://ipykernel.pylab.backend_inline'
But if I run ipython directly in my WSL ubuntu window, and then run the above I get:
In [1]: import matplotlib
In [2]: matplotlib.get_backend()
Out[2]: 'agg'
Any idea how I can determine why this works this way? Is it perhaps part of the anaconda installation, that the kernal determines when it is running in a notebook and automatically switches the backend to 'backend_inline' ??
Thanks. Just curious why this is working this way for me.
RESPONDING TO COMMENTS:
@darthbith, each of these was done with a fresh restart of the kernel:
%matplotlib inline
import matplotlib
matplotlib.get_backend()
'module://ipykernel.pylab.backend_inline'
above is same as when I don't run %matplotlib inline
now restart kernel and try %matplotlib notebook:
%matplotlib notebook
import matplotlib
matplotlib.get_backend()
'nbAgg'
来源:https://stackoverflow.com/questions/57085287/why-dont-i-need-matplotlib-inline-in-my-jupyter-notebook