2

(I hope you get the meaning of what I write, english isn't my mother tongue.)

I have trouble creating a heat map showing air humidity using a txt file. My data looks like this:

26.02.13 10:30:00 MEZ   31.79688    31.0625 32.875  31.8125 31.46875    30.9375 39.0    36.71875    36.1875
26.02.13 10:45:00 MEZ   31.875  31.10938    32.75   31.8125 31.46875    30.9375 39.0    36.71875    36.1875
26.02.13 11:00:00 MEZ   31.82813    31.15625    32.84375    31.8125 31.48438    30.9375 39.0    36.71875    36.1875
...

Its not a matrix, it's:

date1, time1, timezone, value1-room1, value1-room2, value1-room3,...

date2, time2, timezone, value2-room1, value2-room2, value2-room3,...

I inserted a blank line each 96 values to "seperate" the days from each other

this is what my code, so far, looks like(i left out labels etc.):

reset
set cbrange [0:100]
set palette defined (0 '#0000BB',0.091 '#0055FF',0.182 '#44BBEE',0.2728 '#DDFFDD',0.273 '#DDFFBB',0.45 '#DDFF44',0.5 '#FFFF00',0.55 '#FFF600',0.61 '#FFEE00',0.66 '#FFDD00',0.727 '#FFBD00',0.7272 '#FFBB00',0.86 '#FA2200',0.92 '#EA0000',1.0 '#880000')
set cblabel "Humidity"
set cbtics 0,20,100

set timefmt '"%d.%m.%y %H:%M:%S"' 

set format x '"%d.%m.%y"'
set xrange ['"26.02.13"':'"27.03.13"']

set format y '"%H:%M:%S"'
set xrange ['"00:00:00"':'"23:59:59"']

plot "data.txt" using 1:2:4

My intention was to create a heat map for room 1. If that works I want to create heat maps for the other rooms, but first things first :-)

**the problems i can't solve are:

"Skipping unreadable file "data.txt""

and

"Can't plot with an empty x range"**

why is my file unreadable? its in ANSI, the blank lines should tell gnuplot where to start over again

why is the x range empty? did i specify it wrong?

all files are located in the "bin" directory of gnuplot, the "data.txt" has a length of ca. 2000 lines, my gnuplot version is 4.6

thanks in advance

Johannes

JohannesH
  • 21
  • 1

1 Answers1

1

Plotting time data in gnuplot is tricky, but there are a few things to remember:

  1. You should set xdata time somewhere in your script to tell gnuplot that you are working with time.
  2. When it comes to time specifiers, be very careful how your time columns are delimited. If your data file does not have quote characters you do not need them in your specifier.

If your time data spans multiple columns and you say so in your format specifier, gnuplot will figure it out. You only have to specify the column where the time data starts (column 1 in your case).

Here is a script that works for me:

#!/usr/bin/env gnuplot

reset

set terminal pngcairo enhanced color rounded dashed size 800,500
set output 'test.png'

set cbrange [0:100]
set palette defined (0 '#0000BB',0.091 '#0055FF',0.182 '#44BBEE',0.2728 '#DDFFDD',0.273 '#DDFFBB',0.45 '#DDFF44',0.5 '#FFFF00',0.55 '#FFF600',0.61 '#FFEE00',0.66 '#FFDD00',0.727 '#FFBD00',0.7272 '#FFBB00',0.86 '#FA2200',0.92 '#EA0000',1.0 '#880000')
set cblabel "Humidity"
set cbtics 0,20,100

# need these three lines for time data
set xdata time
set timefmt '%d.%m.%y %H:%M:%S' # no quotes in specifier weil sie sind nicht im file
set format x '%d.%m.%y' # no extra quotes here, otherwise they appear in the output

set xrange ['26.02.13':'27.03.13']

# removed y formatting - not sure what you intended there

plot "data.dat" using 1:4 title 'Room 1'

Which makes the following output:

enter image description here

Turning this into a heatmap is another question entirely..

andyras
  • 15,542
  • 6
  • 55
  • 77
  • first: @andyras : thanks a lot for your help here. i thougt to create a heatmap it's important to set x and y-scale (that was my intention with the y-formatting), set the cbrange, set empty lines in my data so that gnuplot knew where to start over again and finally tell gnuplot to use 1(date=x)2(time=y) and 4(data) to create the heat map. is that completely wrong? (i saw you commented in german, do you have a hint for me where i can find a good, ausführliche explanation on plotting heatmaps with gnuplot in german? i have the feeling that it's not only details i didn't get) – JohannesH Jun 16 '14 at 06:10