I use "$ipython notebook --pylab inline" to start the ipython notebook. The display matplotlib figure size is too big for me, and I have to adjust it manually. How to set the default size for the figure displayed in cell?
8 Answers
Worked liked a charm for me:
matplotlib.rcParams['figure.figsize'] = (20, 10)
4 Comments
import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['figure.figsize'] = (20.0, 10.0)plt.rc('figure', figsize=(20.0, 10.0))%matplotlib inline and plt.rc(...) across different cells for the latter to work. Same true for matplotlib.rcParams[...]%matplotlib inlineI believe the following work in version 0.11 and above. To check the version:
$ ipython --version
It may be worth adding this information to your question.
Solution:
You need to find the file ipython_notebook_config.py. Depending on your installation process this should be in somewhere like
.config/ipython/profile_default/ipython_notebook_config.py
where .config is in your home directory.
Once you have located this file find the following lines
# Subset of matplotlib rcParams that should be different for the inline backend.
# c.InlineBackend.rc = {'font.size': 10, 'figure.figsize': (6.0, 4.0), 'figure.facecolor': 'white', 'savefig.dpi': 72, 'figure.subplot.bottom': 0.125, 'figure.edgecolor': 'white'}
Uncomment this line c.InlineBack... and define your default figsize in the second dictionary entry.
Note that this could be done in a python script (and hence interactively in IPython) using
pylab.rcParams['figure.figsize'] = (10.0, 8.0)
6 Comments
ipython_notebook_config.py doesn't contain the line to configure the inline backend. Since the configuration file is not automatically updated when you update iPython (at least on Windows), you need to delete it and generate a new config file by running ipython profile create as suggested by @anmol below.ipython profile locate.matplotlib.rcParams['figure.figsize'] = (10.0, 8.0)ipython_notebook_config.py under my ~. Any idea how things may have changed in the most recent versions?Just for completeness, this also works
from IPython.core.pylabtools import figsize
figsize(14, 7)
It is a wrapper aroung the rcParams solution
1 Comment
In iPython 3.0.0, the inline backend needs to be configured in ipython_kernel_config.py. You need to manually add the c.InlineBackend.rc... line (as mentioned in Greg's answer). This will affect both the inline backend in the Qt console and the notebook.
Comments
You can use "run commands" rc to change the default figure size:
plt.rc('figure', figsize=(w,h))