This is the official manual for the latest Org-mode release.

Table of Contents

Previous: The spreadsheet, Up: Tables


3.6 Org-Plot

Org-Plot can produce graphs of information stored in org tables, either graphically or in ASCII-art.

Graphical plots using Gnuplot

Org-Plot produces 2D and 3D graphs using Gnuplot http://www.gnuplot.info/ and gnuplot-mode http://xafs.org/BruceRavel/GnuplotMode. To see this in action, ensure that you have both Gnuplot and Gnuplot mode installed on your system, then call C-c " g or M-x org-plot/gnuplot <RET> on the following table.

     #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
     | Sede      | Max cites | H-index |
     |-----------+-----------+---------|
     | Chile     |    257.72 |   21.39 |
     | Leeds     |    165.77 |   19.68 |
     | Sao Paolo |     71.00 |   11.50 |
     | Stockholm |    134.19 |   14.33 |
     | Morelia   |    257.56 |   17.67 |

Notice that Org Plot is smart enough to apply the table's headers as labels. Further control over the labels, type, content, and appearance of plots can be exercised through the #+PLOT: lines preceding a table. See below for a complete list of Org-plot options. The #+PLOT: lines are optional. For more information and examples see the Org-plot tutorial at http://orgmode.org/worg/org-tutorials/org-plot.html.

Plot Options
set
Specify any gnuplot option to be set when graphing.
title
Specify the title of the plot.
ind
Specify which column of the table to use as the x axis.
deps
Specify the columns to graph as a Lisp style list, surrounded by parentheses and separated by spaces for example dep:(3 4) to graph the third and fourth columns (defaults to graphing all other columns aside from the ind column).
type
Specify whether the plot will be 2d, 3d, or grid.
with
Specify a with option to be inserted for every col being plotted (e.g., lines, points, boxes, impulses, etc...). Defaults to lines.
file
If you want to plot to a file, specify "path/to/desired/output-file".
labels
List of labels to be used for the deps (defaults to the column headers if they exist).
line
Specify an entire line to be inserted in the Gnuplot script.
map
When plotting 3d or grid types, set this to t to graph a flat mapping rather than a 3d slope.
timefmt
Specify format of Org mode timestamps as they will be parsed by Gnuplot. Defaults to ‘%Y-%m-%d-%H:%M:%S’.
script
If you want total control, you can specify a script file (place the file name between double-quotes) which will be used to plot. Before plotting, every instance of $datafile in the specified script will be replaced with the path to the generated data file. Note: even if you set this option, you may still want to specify the plot type, as that can impact the content of the data file.

ASCII bar plots

While the cursor is on a column, typing C-c " a or M-x orgtbl-ascii-plot <RET> create a new column containing an ASCII-art bars plot. The plot is implemented through a regular column formula. When the source column changes, the bar plot may be updated by refreshing the table, for example typing C-u C-c *.

     | Sede          | Max cites |              |
     |---------------+-----------+--------------|
     | Chile         |    257.72 | WWWWWWWWWWWW |
     | Leeds         |    165.77 | WWWWWWWh     |
     | Sao Paolo     |     71.00 | WWW;         |
     | Stockholm     |    134.19 | WWWWWW:      |
     | Morelia       |    257.56 | WWWWWWWWWWWH |
     | Rochefourchat |      0.00 |              |
     #+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)

The formula is an elisp call:

     (orgtbl-ascii-draw COLUMN MIN MAX WIDTH)
COLUMN
is a reference to the source column.
MIN MAX
are the minimal and maximal values displayed. Sources values outside this range are displayed as ‘too small’ or ‘too large’.
WIDTH
is the width in characters of the bar-plot. It defaults to ‘12’.