2015-09-21 43 views
0

考虑org-模式与巴贝尔以下Python代码块:底纹和matplotlib

#+begin_src python :results none 
import numpy as np 
import matplotlib as mpl 
from matplotlib import pyplot as plt 
graylevel = 0.75 
mpl.rc('figure', facecolor = (graylevel, graylevel, graylevel), edgecolor ='r') 
X = np.linspace(0, 7, 1024) 
plt.plot(X, np.sin(X)) 
plt.plot(X, np.cos(X)) 
plt.draw() 
plt.show() 
#+end_src] 

在弹出窗口中,这产生灰色背景

的曲线图

enter image description here

,但在组织模式投入文件中的情节,当再次(只有最后几行是不同的)

#+begin_src python :results file 
import numpy as np 
import matplotlib as mpl 
from matplotlib import pyplot as plt 
graylevel = 0.75 
mpl.rc('figure', facecolor = (graylevel, graylevel, graylevel), edgecolor ='r') 
X = np.linspace(0, 7, 1024) 
plt.plot(X, np.sin(X)) 
plt.plot(X, np.cos(X)) 
plt.draw() 
plt.savefig('test.png') 
return 'test.png' 
#+end_src 

#+RESULTS: 
[[file:test.png]] 

灰色背景消失

enter image description here

我需要的灰色背景从组织模式导出我的情节,因为我需要从周围文档掀起情节。

我不知道这是matplotlib,org-mode,python,我的机器还是我的问题。我希望有人可以重复这个例子,或者只是知道答案。

回答

2

我不认为这是org-mode的问题,但是是相同的问题discussed here

这是解决你的烦恼:

plt.savefig('test.png', facecolor=(graylevel, graylevel, graylevel))