Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook figure size settings

If I plot a graph or display a table in Jupyter Notebook the figures are really small and unreadable. What is the best way to set the figure size settings globally in Jupyter Notebook? For comparison in Quantopian's Notebook version plots and tables are a lot larger. I know there are separate settings for matplotlib and other libraries but I would like to set global settings. I also tried this setting, but it didn't work.

%config InlineBackend.figure_format='retina' 

enter image description here

enter image description here

like image 409
sabotage3d Avatar asked Nov 12 '17 18:11

sabotage3d


2 Answers

If "globally" means for all successive outputs in a given notebook, I use

plt.rcParams['figure.figsize'] = (16,8)

after importing matplotlib. This affect all subsequent plots. If you wish a single configuration for all notebooks, the reply by Louise Davies is more appropriate.

like image 157
Pierre de Buyl Avatar answered Nov 14 '22 22:11

Pierre de Buyl


I'm pretty sure there's no "global setting" for all packages in jupyter. The best you can do is configure the defaults for matplotlib and pandas etc. Note that other graphing libraries have larger default outputs (from the top of my head I know plotly has full width graphs by default)

To configure global python settings, run ipython profile create to create a ~/.ipython/profile_default/ipython_kernel_config.py file, and add the line:

c.InlineBackend.rc = { 'figure.figsize': (20.0, 10.0) }

See https://matplotlib.org/users/customizing.html for more info on customising matplotlib

As for pandas, I don't think it has global options for style. You could add stuff to jupyter's custom.css file (`~/.jupyter/custom/custom.css) like so:

.dataframe {
    font-size: 14px !important;
}
like image 32
Louise Davies Avatar answered Nov 14 '22 21:11

Louise Davies