How to set matplotlib default font size in ipython laptop?

I use "$ ipython notebook --pylab inline" to start the ipython laptop. The size of the matplotlib shape of the display is too big for me, and I have to adjust it manually. How to set the default size for the shape displayed in the cell?

+72
matplotlib ipython-notebook
Jun 21 '13 at 8:30
source share
5 answers

I believe that the next work is in version 0.11 and higher. To check the version:

$ ipython --version 

It might be worth adding this information to your question.

Decision:

You need to find the ipython_notebook_config.py file. Depending on the installation process, it should be somewhere like

 .config/ipython/profile_default/ipython_notebook_config.py 

where .config is in your home directory.

Once you find 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 can be done in a python script (and therefore interactively in IPython) using

 pylab.rcParams['figure.figsize'] = (10.0, 8.0) 
+105
Jun 21 '13 at 9:01
source share

The work was like a charm for me:

 matplotlib.rcParams['figure.figsize'] = (20.0, 10.0) 
+60
Mar 29 '16 at
source share

If you do not have this ipython_notebook_config.py file, you can create it by following readme and typing

 ipython profile create 
+15
Sep 15 '14 at 20:57
source share

In iPython 3.0.0, the built-in backend must be configured in ipython_kernel_config.py . You need to manually add the line c.InlineBackend.rc ... (as indicated in Greg ). This will affect both the embedded server in the Qt console and the laptop.

+8
Mar 11 '15 at 13:54 on
source share

Just for completeness, it also works

 from IPython.core.pylabtools import figsize figsize(14, 7) 

This is a shell for rcParams solution

+3
Apr 08 '17 at 1:12 on
source share



All Articles