我已经看过问题,但仍然无法使这个工作.
我的数据集是这样的:
[date] , [%cpu] , [mem]
23:00:39 , 21.9 , 2.1
23:00:44 , 21.8 , 2.1
23:00:49 , 21.8 , 2.1
23:00:54 , 21.8 , 2.1
23:00:59 , 21.7 , 2.1
Run Code Online (Sandbox Code Playgroud)
我的Gnuplot语句(刚开始用于此数据)是:
set timefmt "%H:%m:%s"
set xdata time
set datafile sep ','
plot '/tmp/info' using 2 title 'cpu' with lines, '/tmp/info' using 3 title 'memory%' with lines
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Run Code Online (Sandbox Code Playgroud)Need full using spec for x time data
我尝试过自动缩放x,但我有点迷失,任何帮助都会受到赞赏.
时间数据要求您始终指定要使用的所有列.(还要注意更正timefmt):
set timefmt "%H:%M:%S"
set xdata time
set datafile sep ','
set style data lines
plot '/tmp/info' using 1:2 title 'cpu', '' using 1:3 title 'memory%'
Run Code Online (Sandbox Code Playgroud)
原因是,也timefmt可能包含空格,因此用于时间轴的数据可能来自两列.考虑以下修改的数据文件:
23:00:39 06/08/13 21.9 2.1
23:00:44 06/08/13 21.8 2.1
23:00:49 06/08/13 21.8 2.1
23:00:54 06/08/13 21.8 2.1
23:00:59 06/08/13 21.7 2.1
Run Code Online (Sandbox Code Playgroud)
此格式的绘图命令是:
set timefmt "%H:%M:%S %d/%m/%Y"
set xdata time
set format x "%H:%M:%S"
set style data lines
plot 'mydata.dat' using 1:3 t 'cpu', '' using 1:4 t 'memory%'
Run Code Online (Sandbox Code Playgroud)
为避免混淆,始终要求对于时间数据,绘图样式(此处with lines)使用的所有列都与该using语句一起明确给出.