Automatically run %matplotlib inline in IPython Notebook
Every time I launch IPython Notebook, the first command I run is
Is there some way to change my config file so that when I launch IPython, it is automatically in this mode?
The configuration way
IPython has profiles for configuration, located at
~/.ipython/profile_*. The default profile is called
profile_default. Within this folder there are two primary configuration files:
Add the inline option for matplotlib to
c = get_config() # ... Any other configurables you want to set c.InteractiveShellApp.matplotlib = "inline"
matplotlib vs. pylab
%pylab to get inline plotting is discouraged.
It introduces all sorts of gunk into your namespace that you just don't need.
%matplotlib on the other hand enables inline plotting without injecting your namespace. You'll need to do explicit calls to get matplotlib and numpy imported.
import matplotlib.pyplot as plt import numpy as np
The small price of typing out your imports explicitly should be completely overcome by the fact that you now have reproducible code.