2017-03-07 17 views
1

我已經看到這個問題出現了幾次,但我認爲這個信息會隨着jupyter/ipython的更新而改變。我目前正在運行python 3.5,jupyter(latest)和matplotlib 2.0。
%matplotlib inline圖表具有導入matplotlibrc文件後設置的自定義屬性。其中最煩人的是figure.facecolor屬性設置爲透明,這會在複製/粘貼圖時造成嚴重破壞,所以我必須在筆記本中重置此屬性。我似乎無法找到這個屬性改變的地方,或者如果有可能創建一個配置文件的某處改變這些特殊的inline繪圖設置matplotlibrc rcParams修改爲Jupyter內聯圖

我的問題是,是否有可能改變這些設置,如果是這樣,我會那樣做嗎?

+0

所以現在的問題是如何避免在您的筆記本電腦每一次的頂部輸入'plt.rcParams [「figure.facecolor」] =「白色」'。那是對的嗎? – ImportanceOfBeingErnest

+0

是的,這是正確的 –

回答

1

一些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 
    } 

而他們居住的地方是ipykernel/pylab/config.py文件。 可以編輯該文件以獲得所需的行爲,例如,通過將facecolor更改爲'figure.facecolor': (1,1,1,1)(不透明)。

另一種選擇是:

的rcParameters被定義爲InlineBackend類的一部分,特別是InlineBackend.rc屬性其爲traitlets.Dict對象。

這些可以使用ipython configuration system如下更改。

從命令行輸入ipython profile create這將在~/.ipython中生成默認配置文件。在主配置文件~/.ipython/ipython_config.py包括行:

c.InlineBackend.rc.update({"figure.facecolor": "white"})