Files
emacs-conf/scripts/test/test.org

92 lines
1.9 KiB
Org Mode

* scr block
** syntax highlighting
*** graphviz dot
#+begin_src dot :file img/src-dot.svg
digraph G {
main -> parse -> execute;
main -> init;
main -> cleanup;
execute -> make_string;
execute -> printf
init -> make_string;
main -> printf;
execute -> compare;
}
#+end_src
#+ATTR_ORG: :width 300
#+RESULTS:
[[file:img/src-dot.svg]]
*** gnuplot
#+begin_src gnuplot :results silent
reset
set title "Putting it All Together"
set xlabel "X"
set xrange [-8:8]
set xtics -8,2,8
set ylabel "Y"
set yrange [-20:70]
set ytics -20,10,70
f(x) = x**2
g(x) = x**3
h(x) = 10*sqrt(abs(x))
plot f(x) w lp lw 1, g(x) w p lw 2, h(x) w l lw 3
#+end_src
#+NAME: tab-gnuplot
| 3.75 | 2.5 |
| 4.43 | 3 |
| 5.5 | 3 |
| 3.5 | 3.5 |
#+begin_src gnuplot :var data=tab-gnuplot :exports results :file img/gnuplot-tab.svg
set terminal svg size 400,320
plot data u 1 t "unsorted", \
'' u 2 lt 3 t "sorted"
#+end_src
#+RESULTS:
[[file:img/gnuplot-tab.svg]]
** custom header
*** python
- interactive inside org
- html export creates a svg file
- latex export creates a pgf file
#+HEADER: :var fname=(mpl-var "img/peltier-characteristic")
#+HEADER: :epilogue (by-backend (html "fig.savefig(fname);print(fname, end='')") (t "plt.show()"))
#+HEADER: :results (by-backend (html "output file") (t "none"))
#+begin_src python :exports results
import numpy as np
import matplotlib.pyplot as plt
x = [-4, -3, -2, -1, 0, 1, 2, 3]
y1 = [-11.2, -11.6, -7.0, 3.2, 18.3, 39.0, 68.2, 125.0]
y2 = [-8.2, -8.3, -3.9, 7.3, 22.9, 47.3, 87.1, 136.2]
fig, ax = plt.subplots(1, 1, dpi=100, layout='constrained', figsize=[6.4*1.5/2, 4.8*1.5/2])
ax.plot(x, y1, '.-', label='15°C')
ax.plot(x, y2, '.-', label='20°C')
ax.legend()
ax.set_xlabel('Electrical current, A')
ax.set_ylabel('Temperature, °C')
ax.set_title('Characteristic curve of the peltier element')
#+end_src
* latex
=org-startup-with-latex-preview=
\(a=5\)