2021-02-02        ORG-MODE PIECHART IN A HURRY (3D!)


I needed a pie chart, and had very little time. R and Org-mode to the
rescue.

I started on stackoverflow[1]. However, I wanted a slightly more
pronounced image. To save others time, here is how you add plotrix.

The result:

foo.jpg[2]

First, make sure you have plotrix.

,----
|  apt install r-cran-plotrix
`----

,----
|  #+TBLNAME:foo
|  | population in % | continent         |
|  |-----------------+-------------------|
|  |            59.5 | Asia              |
|  |            17.2 | Africa            |
|  |             9.6 | Europe            |
|  |             7.6 | North America     |
|  |             5.5 | South America     |
|  |            0.55 | Australia/Oceania |
|  |          0.0001 | Antartica         |
|
|  (source: https://www.worldometers.info/geography/7-continents/)
|
|
|  #+name: name-of-result-block-in-org-file
|  #+begin_src R :results file graphics :file foo.jpg  :var foo=foo :width 600
|  library(plotrix)
|  pie3D(foo[,1],labels=foo[,2],explode = 0.1, main = "Where people live")
|  #+end_src
`----

You generate the image with C-c C-c anywhere. That will add a few lines

,----
|  #+RESULTS: name-of-result-block-in-org-file
|  [[file:foo.jpg]]
`----

You can read more about Org-mode and R here: https://orgmode.org/worg/org-tutorials/org-R/org-R.html


[1]: https://emacs.stackexchange.com/questions/53416/draw-pie-chart-from-orgmode-table
[2]: gopher://gopher.hillenius.net/I/images/foo.jpg