[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Plotting in Emacs?
From: |
Daniel Fleischer |
Subject: |
Re: Plotting in Emacs? |
Date: |
Sat, 20 May 2023 11:26:32 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Marcin Borkowski [2023-04-18 Tue 06:16] wrote:
> The reason I want this is that I weigh myself every day, I put the
> datapoints in an Org mode table (and use Org spreadsheet to compute
> moving averages), and now I'd like to see a nice chart telling me
> whether my diet works and I'm losing weight. So, calculating linear
> regression (pretty easy with Org mode) and plotting a regression line
> would also be cool.
Plotting == gnuplot. You got to have a library that creates plots out of
data. Here is a snippet I use for the same purpose:
#+begin_src gnuplot :var data=body-data :file a.png
reset
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5
set style line 2 lc rgb '#269C52' lt 1 lw 2 pt 5 pi -1 ps 1.5
set pointintervalbox 3
set title "Body Metrics"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%d/%m/%y"
set key spacing 1.5
set ytics 1
set y2tics 1
set ytics nomirror
set xtics nomirror
set xlabel "Date"
set ylabel "Kg"
set y2label "Fat \%"
set xrange ["2020-08-01":]
set yrange [80:90]
set y2range [10:25]
plot data using 1:2 axis x1y1 with lp ls 1 title 'Weight',\
'' using 1:3 axis x1y2 with lp ls 2 title 'Fat'
#+end_src
#+RESULTS:
[[file:a.png]]
#+NAME: body-data
| Date | Weight | Fat |
|------------------+--------+------|
| [2020-08-04 Tue] | 85.5 | |
| [2020-08-05 Wed] | 85.1 | 18.2 |
| [2020-08-06 Thu] | 86.5 | 18.9 |
| [2020-08-07 Fri] | 85.7 | 18.7 |
| [2020-08-08 Sat] | 85.3 | 18.3 |
| [2020-08-09 Sun] | 85.9 | 18.6 |
Feel free to change the gnuplot parameters for taste and the weight/fat
numbers as well.
--
Daniel Fleischer