Álvaro Ramírez
Plotting ledger reports in org
My ledger file
Save path to my.ledger in ledger-file block.
#+name: ledger-file #+begin_src emacs-lisp "my.ledger" #+end_src
gnuplot terminal (png or qt)
Select gnuplot terminal. Using png to output images, but qt is handy too for interactive chart inspection.
Use png for inline or qt for interactive #+name: gnuplot-term #+begin_src emacs-lisp "png" #+end_src
Monthly Income and Expenses
Generate income report.
#+name: income-data #+begin_src bash :results table :noweb yes ledger -f <<<ledger-file>>> -j reg ^Income -M --collapse --plot-amount-format="%(format_date(date, \"%Y-%m-%d\")) %(abs(quantity(scrub(display_amount))))\n" #+end_src
Generate expenses report.
#+name: expenses-data #+begin_src sh :results table :noweb yes ledger -f <<<ledger-file>>> -j reg ^Expenses -M --collapse #+end_src
Plot income vs expenses.
set terminal myterm size 3500,1500 set style data histogram set style histogram clustered gap 1 set style fill transparent solid 0.4 noborder set xtics nomirror scale 0 center set ytics add ('' 0) scale 0 set border 1 set grid ytics set title "Monthly Income and Expenses" set ylabel "Amount" plot income using 2:xticlabels(strftime('%b', strptime('%Y-%m-%d', strcol(1)))) title "Income" linecolor rgb "light-salmon", '' using 0:2:2 with labels left font "Courier,8" rotate by 15 offset -4,0.5 textcolor linestyle 0 notitle, expenses using 2 title "Expenses" linecolor rgb "light-green", '' using 0:2:2 with labels left font "Courier,8" rotate by 15 offset 0,0.5 textcolor linestyle 0 notitle