all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Fleischer <danflscr@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Plotting in Emacs?
Date: Sat, 20 May 2023 11:26:32 +0300	[thread overview]
Message-ID: <m2r0rbz9vr.fsf@gmail.com> (raw)
In-Reply-To: 87a5z56d0j.fsf@mbork.pl

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




  parent reply	other threads:[~2023-05-20  8:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18  4:16 Plotting in Emacs? Marcin Borkowski
2023-04-18  4:38 ` Jean Louis
2023-05-23 17:14   ` Marcin Borkowski
2023-04-18  7:39 ` Tak Kunihiro
2023-05-20  7:55   ` Marcin Borkowski
2023-05-20  8:26 ` Daniel Fleischer [this message]
2023-05-23 17:18   ` Marcin Borkowski
2023-05-23 18:07     ` Daniel Fleischer
2023-05-24  4:36       ` Marcin Borkowski
2023-05-25  2:32     ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2r0rbz9vr.fsf@gmail.com \
    --to=danflscr@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.