matplotlibrc rcParams modified for Jupyter inline plots

后端 未结 1 1794
星月不相逢
星月不相逢 2020-12-11 05:10

I have seen this question come up a couple of times, but I think this information changes as jupyter/ipython get updated. I am currently running python 3.5, jupyter (latest

相关标签:
1条回答
  • 2020-12-11 05:54

    Some of the rcParameters are set specifically for the inline backend. Those are

    {'figure.figsize': (6.0,4.0),  
     'figure.facecolor': (1,1,1,0), # play nicely with white background in the Qt and notebook
     'figure.edgecolor': (1,1,1,0),      
     'font.size': 10, # 12pt labels get cutoff on 6x4 logplots, so use 10pt.
     'figure.dpi': 72, # 72 dpi matches SVG/qtconsole
     'figure.subplot.bottom' : .125 # 10pt still needs a little more room on the xlabel
      }
    

    And the place where they reside is the ipykernel/pylab/config.py file. This file can be edited to obtain the desired behaviour, e.g. by changing the facecolor to 'figure.facecolor': (1,1,1,1) (no transparency).

    Another option is the following:

    The rcParameters are defined as part of the InlineBackend class, specifically the InlineBackend.rc attribute which is a traitlets.Dict object.

    Those can be changed using the ipython configuration system as follows.

    From the command line type ipython profile create which will generate the default configuration files in ~/.ipython. In the main configuration file ~/.ipython/ipython_config.py include the line:

    c.InlineBackend.rc.update({"figure.facecolor": "white"})
    
    0 讨论(0)
提交回复
热议问题