
* scr block

** syntax highlighting

*** graphviz dot
#+begin_src dot
digraph G {
  main -> parse -> execute;
  main -> init;
  main -> cleanup;
  execute -> make_string;
  execute -> printf
  init -> make_string;
  main -> printf;
  execute -> compare;
}
#+end_src

*** 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


** 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\)
