If my R code, which plots several graphs, is contained within one babel code block in org-mode, is it possible to export all of the graphs and display them in the #+RESULT section after evaluating the code?

  • Using Spacemacs 200.9@25.1.1, Org-mode v.9.0.5, ESS and R 3.3.3

2 Answers 2


You could look into scimax's ob-ipython extensions, as described here.

Quoting the author:

I wrote one new function that writes the base64 data out to a temporary file and returns a link to it. Then, I modified the org-babel-execute:ipython function to append these links onto the output.

The code is written for SRC blocks targetying ipython, but you can probably modify it so that it works for R in the same way. None of the ideas in the implementation seem to be specific to Python.

The scimax ob-ipynb exporter already offers support for R.

  • 1
    I think this would only work if you use R via Jupyter. May 31, 2017 at 16:49

I don't know how to export multiple graphs per one #+RESULTS.

But I might export multiple graphs, or handle multiple inline images within org-mode, by a dirty way.

Just save graph files by png(), pdf(), etc.

#+BEGIN_SRC R :session *R* :results output :exports none
dd<-data.frame(cbind(x=d, y=d^2, z=d^3))
for(i in 1:3){

Then, just make links for each graphic files by hands ;)

If you change the data, such as d<-1:10, and execute the source code block by C-c C-c, you can see multiple inline images reflect the results simultaneously.

Making links with numbering are stupid simple tasks, I'm sure Emacs Lisp handle numbering tasks without difficulty!

#+CAPTION: tmp1
#+NAME: tmp1
#+ATTR_LaTeX: :height 4cm
#+ATTR_HTML: :width 360

#+CAPTION: tmp2
#+NAME: tmp2
#+ATTR_LaTeX: :height 4cm
#+ATTR_HTML: :width 360

#+CAPTION: tmp3
#+NAME: tmp3
#+ATTR_LaTeX: :height 4cm
#+ATTR_HTML: :width 360

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.