introduction
org-mode supports graphing with gnuplot. This can be done directly with
#+plot but it’s very rudimentary. It can also be done with org-babel and I
can still feed tables into it.
reading material and citations
- ob-gnuplot docs
- Has lots of good examples for
gnuplotviaob-gnuplot. - org-plot docs
org-plotdocumentation. Examples feel sparse for my simian mind.- org-plot tutorial
- And has the org mode version I can use as reference.
- Plotting (with gnuplot) using dates timestamps
- Mailing list discussion
showing how
org-timestampcolumns get converted to another format.
plot
ob-gnuplot
ob-gnuplot is the org-babel approach. It’s much more powerful but much more
explicit. Basically it allows expression as pure gnuplot code.
reset
The *gnuplot* buffer is basically a repl for gnuplot. In order to ensure
settings don’t bleed over between evaluations, use reset to make sure prior
runs don’t influence the current run.
reset
separator
Tables fed to gnuplot are tab separated. Set this to properly distinguish
columns apart from each other.
set datafile separator "\t"
dates
Dates are harder to work with. There’s a few gnuplot settings that are just a
given with dates/times. The dates provided by org-timestamp are converted to
the format YYYY-MM-DD-hh:mm:ss. The hours, minutes, and seconds are all always
“00”. This is determinable by looking at the *gnuplot* buffer, which will show
a temporary path where the file will be emitted such as
/var/folders/2g/7v48qrcn2nqgm9_dl173mhd80000gn/T/babel-3445j1/gnuplot-344q9h.
working example
“Real” data!
| time | ufo sightings | taylor swift songs produced |
|---|---|---|
| 1 | 45 | |
| 2 | 24 | |
| 6 | 12 | |
| 30 | 5 | |
| 50 | 3 |
reset
# org-babel passes gnuplot a payload that's tab separated.
set datafile separator "\t"
set xdata time
set xlabel "time"
set yrange [0:]
# This is the format that org-babel sends to gnuplot.
set timefmt "%Y-%m-%d-%H:%M:%S"
set xrange ["2010-12-03-00:00:00":]
set format x '%Y-%m-%d'
set xtics format "%b %d"
# 564 is the magical width of 80 columns at the present font settings.
set term png size 564, 400
plot data u 1:2 w linespoints title 'ufo sightings', \
data u 1:3 w linespoints title 'taylor swift songs produced'