GNUPLOT如果我有30个数据/1秒代码不工作,为什么?

GNUPLOT如果我有30个数据/1秒代码不工作,为什么?,gnuplot,Gnuplot,Hy 我想知道当我使用相同的代码时,数据仅为1秒/1秒-代码正在工作, 但当我将传感器采样率更改为约30 Hz时,30 data/1秒我得到了以下曲线图: 我想这样说: 我使用的代码是: set term png set autoscale yfix set autoscale xfix set grid #set offsets 0,0,30,30 #set offsets 0,0,30,30 set offsets graph 0, 0, 50, 50 PATCH = system("c

Hy 我想知道当我使用相同的代码时,数据仅为1秒/1秒-代码正在工作, 但当我将传感器采样率更改为约30 Hz时,30 data/1秒我得到了以下曲线图:

我想这样说:

我使用的代码是:

set term png
set autoscale yfix
set autoscale xfix 
set grid
#set offsets 0,0,30,30
#set offsets 0,0,30,30
set offsets graph 0, 0, 50, 50

PATCH = system("cat ./outputs/lastPatch.txt")

set title "MPU-9150 IMU sensor: RAW Accelerometer "
set xdata time
set timefmt '%H:%M:%S'
set format x '%H:%M:%S'
set xtics rotate
set xlabel "[time]"
set ylabel "[-]"
#set output "./outputs/IMUrawAccel.png"
set output sprintf("%sIMUrawAccel.png",PATCH)
#plot './outputs/IMUrawAccel.txt' using 1:2 title 'X' with lines, './outputs/IMUrawAccel.txt' using 1:3 title 'Y' with lines  , './outputs/IMUrawAccel.txt' using 1:4 title 'Z' with lines   
plot sprintf("%sIMUrawAccel.txt",PATCH) using 1:2 title 'X' with lines, sprintf("%sIMUrawAccel.txt",PATCH) using 1:3 title 'Y' with lines  , sprintf("%sIMUrawAccel.txt",PATCH) using 1:4 title 'Z' with lines
传感器的输出就是我在gnuplot中使用的

22:20:59         2704       -1310      -15666   
22:20:59         2886       -1278      -15716   
22:20:59         2860       -1322      -15734   
22:20:59         2844       -1322      -15684   
22:20:59         2854       -1362      -15680   
22:20:59         2834       -1242      -15766   
22:20:59         2864       -1320      -15830   
22:20:59         2836       -1304      -15724   
22:20:59         2882       -1342      -15744   
22:20:59         2888       -1266      -15794   
22:20:59         2940       -1336      -15774   
22:20:59         2866       -1282      -15786   
22:20:59         2860       -1320      -15756   
22:20:59         2810       -1340      -15710 

存在具有相同时间戳的多个数据点

所以,如果你用时间戳来绘制它们,它们最终会在同一个x坐标上

有几种可能的解决办法

将传感器输出更改为包括,例如毫秒。这是迄今为止首选的解决方案。 如果有固定数量的点具有相同的时间戳,比如说30,您可以使用each关键字:plot sprintf%sIMUrawAccel.txt,使用1:2标题“X”和线每隔30进行一次修补 如果不可能,请编写脚本以增强时间戳。计算具有相同时间戳的数据点的数量,然后向每个时间戳添加一些毫秒,以使它们均匀地隔开。当然,假设数据是均匀分布的。 只需绘制没有时间的点:plot sprintf%sIMUrawAccel.txt,使用2个标题“X”和线进行修补
好的,源数据中的时间戳只有1秒的分辨率,因此每个条目都有30个点的结果是不合理的。您将需要以更高的分辨率生成日志数据,或者如果点在时间上均匀分布,则您可以基于行号而不是使用显式时间戳来推断时间轴。是否可以仅绘制例如30年代的数据?如果是的话,怎么办?时间不是来自传感器,而是来自RTC实时时钟模块