Vin*_* W. 6 python matplotlib ipython jupyter
我已经看到这个问题出现了几次,但我认为随着 jupyter/ipython 的更新,这些信息会发生变化。我目前正在运行 python 3.5、jupyter(最新)和 matplotlib 2.0。
这些%matplotlib inline图具有在导入 matplotlibrc 文件后设置的自定义属性。其中最烦人的是该figure.facecolor属性设置为透明,这在复制/粘贴图时会造成严重破坏,因此我必须在笔记本中重置此属性。我似乎无法找到更改此属性的位置,或者是否可以在某处创建配置文件来更改这些特殊inline绘图设置
我的问题是,是否可以更改这些设置,如果可以,我该怎么做?
一些 rcParameters 是专门为inline后端设置的。那些是
{'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
}
Run Code Online (Sandbox Code Playgroud)
他们驻留的地方是ipykernel/pylab/config.py文件。可以编辑此文件以获得所需的行为,例如通过将 facecolor 更改为'figure.facecolor': (1,1,1,1)(无透明度)。
另一种选择如下:
rcParameters 被定义为InlineBackend类的一部分,特别是InlineBackend.rc属性是一个traitlets.Dict对象。
这些可以使用ipython 配置系统进行更改,如下所示。
从命令行类型ipython profile create生成默认配置文件~/.ipython。在主配置文件中~/.ipython/ipython_config.py包含以下行:
c.InlineBackend.rc.update({"figure.facecolor": "white"})
Run Code Online (Sandbox Code Playgroud)