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
?
Matplotlib is a plotting library. It relies on some backend to actually render the plots. The default backend is the agg backend.
To check that pylab/pyplot backend of Matplotlib runs inline, we can use get_backend() method. The method returns the name of the current backend.
By default, Matplotlib should automatically select a default backend which allows both interactive work and plotting from scripts, with output to the screen and/or to a file, so at least initially, you will not need to worry about the backend.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With