Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

python - Change default backend for matplotlib in Jupyter Ipython

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...