1

Laptop temperature based on running kernelkey

I'm trying to plot temperatures of my laptop, here are my working files at github

I have epoch, temperature & kernel identifier data like so:

1357786501 72 3.6.11-1-ARCH
1357786801 72 3.6.11-1-ARCH
1357787101 60 3.0.57-1-lts
1357787401 54 3.0.57-1-lts
1357800301 52 3.0.57-1-lts
1357800601 48 3.6.11-1-ARCH
1357800902 45 3.6.11-1-ARCH

The closest I've got to what I want is (using this):

set term svg size 1024,708
set xdata time
set key outside
set timefmt "%s"
set ytics 5
set format x "%d/%m"
plot "< awk '{if($3 == \"3.0.57-1-lts\") print}' temp.csv" u 1:2 t column(3) w p pt 2, \
 "< awk '{if($3 == \"3.6.10-1-ARCH\") print}' temp.csv" u 1:2 t column(3) w p pt 2, \
 "< awk '{if($3 == \"3.6.11-1-ARCH\") print}' temp.csv" u 1:2 t column(3) w p pt 2, \
 "< awk '{if($3 == \"3.8.1-1-mainline-dirty\") print}' temp.csv" u 1:2 t column(3) w p pt 2

gihub kaihendry

Is there a way to avoid using awk? When I don't use this awk, it fails to plot differing kernel identifiers.

Can I make it a continuous line with different colours instead somehow?

Any ideas how to make SVG output without width/height? Any tricks to make it look better?

Machavity
  • 30,841
  • 27
  • 92
  • 100
hendry
  • 9,725
  • 18
  • 81
  • 139

1 Answers1

1

If your version of Gnuplot is recent enough, you can use a for-loop and iterator to loop over the different strings you want to match, see for example manual page 88-89 or this blog entry. To ignore non-matching lines you can use the ternary operator (cond ? iftrue : iffalse) to set these values to "Not-A-Number" (1/0 or NaN):

set xdata time
set key outside
set timefmt '%s'
set ytics 5
set format x '%d/%m'
set style data linespoints
archs = "`cut -d' ' -f3 temp.csv | sort -u | tr '\n' ' '`"
plot for [arch in archs] 'temp.csv' using 1:((strcol(3) eq arch) ? $2:1/0) title arch
Thor
  • 45,082
  • 11
  • 119
  • 130
  • Is there no way to avoid manually putting in '3.6.11-1-ARCH 3.0.57-1-lts 3.6.11-1-ARCH' ? `awk '{print $3}' temp.csv | sort -u` – hendry Jan 14 '13 at 08:55
  • @hendry: not that I'm aware of. – Thor Jan 14 '13 at 08:57
  • I have a strange plot on the bottom left, 0 on the X axis: http://s.natalian.org/2013-01-14/1358154089_1366x768.png – hendry Jan 14 '13 at 09:02
  • Great stuff Thor, except do you see the strange plot on the bottom left ? – hendry Jan 14 '13 at 09:13
  • @hendry: yes this is very odd. The numbers that Gnuplot generates make it look like there's a bug somewhere. You can get the raw numbers by inserting `set table 'out.txt'` before the `plot` command. – Thor Jan 14 '13 at 09:26
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22700/discussion-between-thor-and-hendry) – Thor Jan 14 '13 at 10:03
  • I'm convinced 1:((strcol(3) == arch) ? $2 : '?') is wrong since it excludes the y-value, but not the x-value. – hendry Jan 15 '13 at 14:05
  • @hendry: The `'?'` tells Gnuplot that the data for this x-value is missing and should be ignored, see for example `help missing` on the Gnuplot command line. – Thor Jan 15 '13 at 14:23
  • Though '1/0' instead of '?' works... getting tired of GNUplot's arcane abbreviations... Anyway, I'm happy with what I have now upon https://github.com/kaihendry/laptemp#readme – hendry Jan 15 '13 at 15:13