gnuplot在X轴上带有时间的多行 [英] gnuplot multiple lines with Time on X axis

查看:46
本文介绍了gnuplot在X轴上带有时间的多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了一些问题,但仍然无法解决问题.

I've had a look through questions but still can't get this working.

我的数据集是这样的:

[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

我的Gnuplot语句(刚开始用于此数据)是:

My Gnuplot statements (just started using for this data) is:

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

我收到以下错误:

    Need full using spec for x time data

我已经尝试过自动缩放x,但是我有点迷失了,任何帮助将不胜感激.

I've tried autoscale x , but I'm a bit lost, any help would be appreciated.

推荐答案

时间数据要求您始终指定要使用的所有列. (请注意更正后的timefmt):

Time data requires that you always specify all columns to be used. (Note also the corrected 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%'

这样做的原因是,timefmt也可能包含空格,因此用于时间轴的数据可能来自两列.考虑以下修改后的数据文件:

The reason for this is, that the timefmt may also contain spaces, so that the data used for the time axis may come from two columns. Consider the following modified data file:

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

此格式的绘图命令为:

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%'

为避免混淆,对于时间数据,始终要求使用using语句显式给出绘图样式(此处为with lines)使用的所有列.

To avoid confusion, it is always required that for time data all columns used by the plotting style (here with lines) are given explicitely with the using statement.

这篇关于gnuplot在X轴上带有时间的多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆