Right now the default backend for matplotlib is 'module://ipykernel.pylab.backend_inline'
I want to switch that to TkAGG. I edited the matplotlibrc file in
~/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc/
to add
backend : TkAgg
and It did switch the backend for the python but not in Jupyter.
For now everytime I start a new notebook in Jupyter, I have to do %matplotlib tk, isnt there a nice way to make TkAGG the default backend in Jupyter?
解决方案
The question is similar to Automatically run %matplotlib inline in IPython Notebook, except that you want to automatically use TK backend instead of inline backend.
So the idea is to locate you IPython configuration file. See configure IPython. It should be
/.ipython/profile_default/ipython_kernel_config.py
If it doesn't yet exist, create it via > ipython profile create.
Inside this file locate the setting c.InteractiveShellApp.matplotlib and set it to "tk". It should then look like
## Configure matplotlib for interactive use with the default matplotlib backend.
c.InteractiveShellApp.matplotlib = "tk"
Save the file and restart the kernel.