emacs - 组织模式代码块评估

标签 emacs org-mode

在 Org 模式下,我试图将数据从一个小的 Python 2-liner“管道”到 Gnuplot,但我无法弄清楚如何正确地做到这一点(Gnuplot 图像保持在 0kb)。这就是我在此期间取得的进展:

 #+NAME: foo
 #+begin_src python :exports code
   import random
   for x in range (0,300):
    print random.randrange(1000), random.randrange(1000)
 #+end_src

#+begin_src gnuplot :file gnuplot.png :exports results
  reset
  plot call_foo notitle
 #+end_src

谁能完成这项工作?

最佳答案

我在 emacs 中的 gnuplot 目前无法正常工作,因此我无法给出完整的工作答案。但是,:exports python 位的属性应该是 output ,而不是 code .此外,要在 gnuplot session 中访问这些数据,您可能希望将其作为表格读取。因此,如果您的 python 代码为:

#+name: foo
#+begin_src python :exports results
  import random
  for x in range(0,300):
      print random.randrange(1000), random.randrange(1000)
#+end_src

您会希望您的 gnuplot session 将结果表作为变量读取
#+name: plot-it(data = foo)
#+begin_src gnuplot :file gnuplot.png
  plot data notitle
#+end_src

您可能需要对 data 进行一些处理gnuplot 代码中的变量,以确保它是适当的格式。正如我上面所说,我目前无法对此进行测试,但它应该是一个起点。

关于emacs - 组织模式代码块评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9456714/

相关文章:

emacs - 在 Emacs : Only change the background color 中自定义高亮面

emacs - 将组织模式表中的垂直线导出到 LaTeX

emacs - 如何使用 Emacs + org-mode + visual-line-mode 保持缩进?

emacs - 一段elisp 代码 "yield"可以让emacs 不阻塞吗?

突出显示 Lisp 形式的 Emacs 模式

emacs - Emacs 中的 super 键绑定(bind)

emacs - 在 Emacs 中编辑 Markdown 管道表

emacs - 如何让emacs shell自动执行init文件?

Emacs Evil <E> 模式和组织模式

emacs - 如何在 Org 模式下进行内联注释?