Org Mode Python Plotting and Return values

Testing out some python code blocks in org babel. See http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

import matplotlib, numpy
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(4,2))
x=numpy.linspace(-15,15)
plt.plot(numpy.sin(x)/x)
fig.tight_layout()
plt.savefig('python-matplot-fig.png')
return 'python-matplot-fig.png' # return filename to org-mode
Sample plot

Sample plot

def foo(x):
    bar=[1,2,3]
    baz=42
    qux=[[1,2,3],[4,5,6]]

    if x>0:
        return bar

    else:
        return qux

return foo(-5)
1 2 3
4 5 6

Org Mode Table Sorting

  • hit C-c ^
  • key is there has to be horizontal lines before and after.
  • it sorts on column you are on
  • Understands basic times (hh:mm)
  • Understands org-ish dates <2015-07-04 Sat>
  • Does not understand numbers with commas
Name Phone Age Time Date
Peter 1234 17 2:00  
Anna 4321 25 1:00  
Mary 0124 45 6:00  
Mary 0124 45 6:00 <2015-07-01 Wed>
Peter 1234 17 2:00 <2015-07-03 Fri>
Anna 4321 25 1:00 <2015-07-04 Sat>

See:

My last csh script is gone, replaced by org-fied bash

My oldest extant operational script was the one I used to back up my files at home. It’s now gone and has become a small literate programming (you be the judge) example, complete with definition of key environment variables in org-mode data blocks which are then defined in bash via eval, and in-line collection of run results (via :results prepend)

https://github.com/eludom/dotfiles/blob/e407058bd499e9a89a03774bd695c49e33a65860/bin/backup.org