Praveen Kumar

Eternal Quest for Incremental Improvement

Plotting a Weight Chart Using Emacs Org-Mode and Gnuplot

| Comments

I discovered about Org-Mode a couple of years ago. Since then, I have started using it for various tasks. One of the recent usage is to track my daily weight. This article describes how to use Org-Mode and Gnuplot to plot your weight measurements.

Here is the list of software that I use in my setup.

For the purpose of this article, it is assumed that you have a similar setup that works for you.

As part of my daily measurement, I track three measurements namely, weight, body fat percentage and body water percentage. This data can be represented in an Org table that has four columns as follows. Please note that the data provided below is hypothetical.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#+PLOT: script:"Weight.plt"
| Date       | Weight |  BF% |  BW% |
|------------+--------+------+------|
| 05/01/2011 |  145.2 | 30.3 | 50.3 |
| 05/02/2011 |  145.1 | 29.4 | 50.7 |
| 05/03/2011 |  144.2 | 30.1 | 50.4 |
| 05/04/2011 |  144.0 | 29.0 | 50.8 |
| 05/05/2011 |  144.1 | 28.7 | 51.0 |
| 05/06/2011 |  144.2 | 29.2 | 50.7 |
| 05/07/2011 |  144.4 | 27.8 | 51.4 |
| 05/08/2011 |  143.7 | 27.6 | 51.5 |
| 05/09/2011 |  143.2 | 28.5 | 51.0 |
| 05/10/2011 |  142.8 | 30.1 | 50.4 |
| 05/11/2011 |  142.2 | 30.1 | 50.4 |
| 05/12/2011 |  142.4 | 29.8 | 50.5 |
| 05/13/2011 |  142.2 | 29.9 | 50.5 |
| 05/14/2011 |  141.2 | 27.4 | 51.6 |
| 05/15/2011 |  141.5 | 27.2 | 51.7 |
|------------+--------+------+------|
| 05/16/2011 |  141.2 | 28.8 | 51.0 |
| 05/17/2011 |  140.8 | 28.9 | 50.9 |
| 05/18/2011 |  140.2 | 29.5 | 50.7 |
| 05/19/2011 |  140.5 | 26.8 | 51.9 |
| 05/20/2011 |  140.4 | 28.1 | 51.3 |
| 05/21/2011 |  139.2 | 26.7 | 51.9 |
| 05/22/2011 |  137.1 | 27.0 | 51.7 |
| 05/23/2011 |  137.5 | 27.0 | 51.7 |
| 05/24/2011 |  137.4 | 28.5 | 51.1 |
| 05/25/2011 |  136.8 | 29.6 | 50.6 |
| 05/26/2011 |  136.3 | 28.8 | 51.0 |
| 05/27/2011 |  136.3 | 28.2 | 51.2 |
| 05/28/2011 |  136.3 | 28.9 | 50.9 |
| 05/29/2011 |  136.2 | 28.0 | 51.3 |
| 05/30/2011 |  135.9 | 28.8 | 50.9 |
| 05/31/2011 |  135.5 | 28.2 | 51.2 |
|------------+--------+------+------|
| 06/01/2011 |  135.1 | 28.2 | 51.2 |
| 06/02/2011 |  135.5 | 28.2 | 51.2 |
| 06/03/2011 |  134.8 | 28.9 | 50.9 |
| 06/04/2011 |  134.4 | 29.6 | 50.6 |
| 06/05/2011 |  134.2 | 27.9 | 51.3 |
| 06/06/2011 |  134.4 | 28.1 | 51.3 |
| 06/07/2011 |  133.2 | 29.2 | 50.8 |
| 06/08/2011 |  133.1 | 28.8 | 51.0 |
| 06/09/2011 |  133.0 | 28.6 | 51.0 |
| 06/10/2011 |  133.2 | 27.8 | 51.4 |
| 06/11/2011 |  132.2 | 27.9 | 51.4 |
| 06/12/2011 |  132.0 | 27.9 | 51.4 |
| 06/13/2011 |  132.1 | 28.9 | 51.0 |
| 06/14/2011 |  131.0 | 29.0 | 50.9 |
| 06/15/2011 |  130.2 | 27.6 | 51.5 |
|------------+--------+------+------|

I use the following Gnuplot script, Weight.plt that plots the weight, body fat percentage, absolute body fat, body water percentage and absolute body water.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Weight plotter.

set terminal aqua title "Weight plot"
set xdata time
set timefmt '"%m/%d/%Y"'
set xlabel 'Date'

set multiplot

set size 1, 0.33

# Weight.
set origin 0, 0.66
set ylabel 'Weight in lb'
plot '$datafile' using 1:2 title 'Weight' with lines linecolor 2

set size 0.5, 0.33

# Body fat.
# Percentage.
set origin 0, 0.33
set ylabel 'Body fat %'
plot '$datafile' using 1:3 title 'Body fat %' with lines linecolor 1
# Absolute.
set origin 0.5, 0.33
set ylabel 'Body fat in lb'
plot '$datafile' using 1:($3 * $2 / 100) title 'Body fat' with lines linecolor 1

# Body water.
# Percentage.
set origin 0, 0
set ylabel 'Body water %'
plot '$datafile' using 1:4 title 'Body water %' with lines linecolor 3
# Absolute.
set origin 0.5, 0
set ylabel 'Body water in lb'
plot '$datafile' using 1:($4 * $2 / 100) title 'Body water' with lines linecolor 3

unset multiplot

Here is the screenshot of the generated plot. Click the thumbnail to get the actual size.

Weight Chart

Comments