5

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

sabotage3d
  • 435
  • 1
  • 6
  • 15

2 Answers2

8

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.

Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22
4

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;
}
Louise Davies
  • 14,781
  • 6
  • 38
  • 41
  • 2
    In fact, with my ipython version `6.4.0`, only by adding the `c.InlineBackend.rc = { 'figure.figsize': (20.0, 10.0) }` line to `ipython_kernel_config.py` works. The other solution using `plt.rcParams['figure.figsize'] = (16,8)` doesn't work first time. One needs to run the cell twice for some reason for it to work. – tsando Nov 07 '18 at 16:57