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 can produce 2D and 3D graphs of information stored in Org tables using Gnuplot and Gnuplot mode. 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
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
β keyword preceding a table. See below for a complete list of Org Plot options. For more information and examples see the Org Plot tutorial.
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 is β2d
β, β3d
β, or βgrid
β.
βwith
ββ
Specify a βwith
β option to be inserted for every column being plotted, e.g., βlines
β, βpoints
β, βboxes
β, βimpulses
β. 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 point is on a column, typing C-c `` a
or M-x orgtbl-ascii-plot
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.
function
orgtbl-ascii-draw value min max \&optional widthβ
Draw an ASCII bar in a table.
VALUE
is the value to plot.
MIN
is the value displayed as an empty bar. MAX
is the value filling all the WIDTH
. Sources values outside this range are displayed as βtoo small
β or βtoo large
β.
WIDTH
is the number of characters of the bar plot. It defaults to β12
β.