2

(我希望你明白我写的意思,英语不是我的母语。)

我无法使用 txt 文件创建显示空气湿度的热图。我的数据如下所示:

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
...

它不是矩阵,它是:

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

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

我在每个 96 个值中插入一个空行,以“分隔”彼此的日子

到目前为止,这就是我的代码的样子(我省略了标签等):

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

我的意图是为房间 1 创建热图。如果可行,我想为其他房间创建热图,但首先要做的事情是 :-)

**我无法解决的问题是:

"跳过不可读的文件 "data.txt""

“不能用空的 x 范围绘图”**

为什么我的文件不可读?它在 ANSI 中,空白行应该告诉 gnuplot 从哪里重新开始

为什么 x 范围为空?我指定错了吗?

所有文件都位于 gnuplot 的“bin”目录中,“data.txt”的长度为 ca。2000行,我的gnuplot版本是4.6

提前致谢

约翰内斯

4

1 回答 1

1

在 gnuplot 中绘制时间数据很棘手,但有几点需要记住:

  1. 您应该set xdata time在脚本中的某个地方告诉 gnuplot 您正在处理时间。
  2. 当涉及到时间说明符时,要非常小心你的时间列是如何分隔的。如果您的数据文件没有引号字符,则说明符中不需要它们。

如果您的时间数据跨越多个列,并且您在格式说明符中这么说,gnuplot 会计算出来。您只需指定时间数据开始的列(在您的情况下为第 1 列)。

这是一个适合我的脚本:

#!/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'

这会产生以下输出:

在此处输入图像描述

把它变成热图完全是另一个问题。

于 2014-06-13T15:22:22.250 回答