fix ob-python

This commit is contained in:
2025-06-17 17:21:04 +02:00
parent 56022f7f8b
commit 280b19d614
3 changed files with 48 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
* syntax highlighting
* graphviz dot
** graphviz dot
#+begin_src dot
digraph G {
main -> parse -> execute;
@@ -14,7 +15,7 @@ digraph G {
}
#+end_src
* gnuplot
** gnuplot
#+begin_src gnuplot :results silent
reset
@@ -35,3 +36,30 @@ 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