Search code examples
emacsgnuplotorg-mode

creating spider plots from org-mode tables


What would be the easiest way to create a spider plot (or radar/star plot) from an org-mode table using org-plot/gnuplot?

The org-plot docs suggests it should be possible using a script: option but it's not clear to me how the table columns can be converted into arrays in a gnuplot script (using this example code as a starting point)

The input would look something like this...

#+PLOT: title:"spiderplot" set:"output './img/spiderplot.png'" script:"spiderplot.gp"
#+TBLNAME: three-fold
| Array1 | Array2 |  Array3 |
|     15 |     25 |      30 |
|     75 |     25 |      35 |
|     20 |     50 |      55 |
|     43 |     50 |      55 |
|     90 |     75 |      80 |
|     50 |     50 |      25 |

and produce an image something like this...

enter image description here


Solution

  • Based on Ethan's answer, org-plot creates a temp file which can be referenced as $datafile in the gnuplot script. The sep isn't required (as it's set on export) and the png options may need to be set...

    set spiderplot
    set style spiderplot fillstyle transparent solid 0.30 border
    set for [i=1:6] paxis i range [0:100]
    set for [i=1:6] paxis i label sprintf("Score %d",i)
    set paxis 1 tics
    set grid spider lt black lw 0.2
    
    set terminal png notransparent truecolor enhanced large
    
    plot for [row=1:6] '$datafile' using 1 every 1::row::row lt 0, newspiderplot, \
         for [row=1:6] '$datafile' using 2 every 1::row::row lt 1, newspiderplot, \
         for [row=1:6] '$datafile' using 3 every 1::row::row lt 2