gnuplot ASCII graph is amazing. I'd like to include gnuplot dumb ASCII graph results in babel code block.
#+BEGIN_SRC gnuplot :results output :file gnuplot-dumb-plot.txt
set term dumb
set yrange [0:1.5]
plot [-2:2] exp(-x*x)
#+END_SRC
#+RESULTS:
Alas, first line of gnuplot-dumb-plot.txt includes ^L
line feed control code.
Therefore, #+RESULTS:
does not work.
Adding another #+INCLUDE:
with example block specified does work.
#+INCLUDE: gnuplot-dumb-plot.txt example
or excluding first line with :lines
specified,
#+INCLUDE: gnuplot-dumb-plot.txt example :lines "2-"
or by sed deleting first line
#+BEGIN_SRC sh
sed -e '1d' gnuplot-dumb-plot.txt
#+END_SRC
work, but are not elegant.
#+RESULTS:
#+begin_example
+--------+-------+--------+--------+-------+--------+-------+--------+
1.4 +-+ + + + + + + + +-+
| exp(-x*x) ******* |
| |
1.2 +-+ +-+
| |
1 +-+ **** +-+
| **** **** |
| *** *** |
0.8 +-+ * * +-+
| ** ** |
0.6 +-+ ** ** +-+
| ** ** |
| ** ** |
0.4 +-+ ** ** +-+
| *** *** |
0.2 +-+ *** *** +-+
| *** *** |
+ ****** + + + + + ****** +
0 ****-----+-------+--------+--------+-------+--------+-------+-----****
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
#+end_example
Are there any options or hacks for including gnuplot dumb ASCII graphs?
Thanks to @wvxvw, it turned out to be:
- Note: Emacs 24.5.1, org-mode 8.3.2, gnuplot Version 5.0 patchlevel 1, Mac OS X 10.10.5.
:session none
is required in gnuplot code block for printing ASCII graph in#+RESULTS:
.- I wish if gnuplot has an option such as
noheadfeed
for deleting a top^L
/ or, perhaps org-babel might manage in the future.
- I wish if gnuplot has an option such as
HTML export
:results output verbatim
in gnuplot code block enables printing ASCII graph at#+RESULTS:
within org-mode.org-html-export-as-html
works. This seems to be a simple solution if you don't need LaTeX.- But
^L
appears in the beginning of#+RESULTS:
which later makes error at LaTeX.
LaTeX export
- Due to
^L
, "Forbidden control sequence" in LaTeX,org-latex-export-to-pdf
fails. - For LaTeX export, do not
C-c C-c
at gnuplot code block.#+RESULTS:
at gnuplot should be left blank. :exports none
is also required in gnuplot code block for avoiding LaTeX error.
- Due to
Org-mode, HTML, LaTeX
- @wvxvw's solution removing
^L
(\014
) succeeds in org-mode#+RESULTS
, HTML/LaTeX exports. - Use
#+NAME:
,:var
,#+CALL:
for output a clean ASCII graph#+RESULTS:
(without^L
)
- @wvxvw's solution removing
:var=graph()
(assuming you previously named the GNUPlot block with#+name: graph
) and then remove the extra line in the output.