Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does org-babel export a ggplot graph fine with C-c C-c but not with export or publish?
    primarykey
    data
    text
    <p>I have a code block with a simple command:</p> <pre><code>#+begin_src R :results output graphics :exports results :file a.png print(qplot(a,binwidth=1)+opts(title="graph title")+scale_x_continuous("axis lable")+scale_y_continuous(formatter="comma")) #+end_src </code></pre> <p>I load ggplot2 in an earlier block of this session, and it works fine when I do <code>C-c C-c</code> to execute that block.</p> <p>When I try <code>C-c C-e h</code> or <code>C-c C-e P</code> to export or publish the file, it writes an a.png of length 0.</p> <p>Here are some of the <code>#+</code> lines at the start of this file:</p> <pre><code>#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t &lt;:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:info toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+BABEL: :session *R* :cache yes :exports both :tangle yes </code></pre> <p>I'm running "GNU Emacs 23.3.1 (i386-mingw-nt5.2.3790) of 2011-03-10 on 3249CTO" on an XP64 system and "Org-mode version 7.5".</p> <p>What am I missing? I didn't find the answer in my search of Stack Overflow, the org-mode mailing list, the manuals, or Google.</p> <p>I tried a simple, executable file this morning:</p> <pre><code>#+TITLE: test.org #+AUTHOR: #+EMAIL: me #+DATE: 2012-03-01 Thu #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t &lt;:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: #+XSLT: #+BABEL: :session *R* :cache yes :exports both :tangle yes * Test of R #+begin_src R :results output :export both summary(rnorm(25)) #+end_src #+results: * Test of ggplot2 #+begin_src R :results output graphics :exports results :file testggplot.png library(ggplot2) qplot(runif(25)) #+end_src </code></pre> <p>Each code block executes fine with <code>C-c C-c</code>. Running <code>C-c C-e h</code> or <code>C-c C-e b</code> to export as HTML gives problems with a big clue: it writes the file testggplot.png with the contents </p> <pre><code>stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this. </code></pre> <p>My conjecture: I got a 0-length .png file above because it didn't need to write an error message.</p> <p>If I run <code>C-c C-c</code> first, I get a <code>#+results[</code> section in the .org file with a link to <code>testggplot.png</code>. I can see the graph in the .org file, if I turn on iimage-mode.</p> <p>If I then run <code>C-c C-e h</code>, I get a valid HTML file with the graph.</p> <p>Does that (or the ECM) give any clues that might show me what to do (besides running <code>C-c C-c</code> on every code block first)?</p> <p>UPDATE 2: perhaps snippets of the HTML org-mode produces provide insight. </p> <p>If I have run <code>C-c C-c</code> first, such that the graphic file has been written, then I get</p> <pre><code>&lt;div id="outline-container-2" class="outline-2"&gt; &lt;h2 id="sec-2"&gt;&lt;span class="section-number-2"&gt;2&lt;/span&gt; Test of ggplot2 &lt;/h2&gt; &lt;div class="outline-text-2" id="text-2"&gt; &lt;p&gt; &lt;img src="testggplot.png" alt="testggplot.png" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>If I have not created the file first, then I get</p> <pre><code>&lt;div id="outline-container-2" class="outline-2"&gt; &lt;h2 id="sec-2"&gt;&lt;span class="section-number-2"&gt;2&lt;/span&gt; Test of ggplot2 &lt;/h2&gt; &lt;div class="outline-text-2" id="text-2"&gt; &lt;pre class="example"&gt; testggplot.png &lt;/pre&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The only difference seems to be whether it wraps the file name in a <code>&lt;pre&gt;</code> block as text or whether it wraps it as an image. Of course, in the first case, it also fails to write a .png file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload